WPS Office.apk(点击下载) / AppsFlyerLib.java


package com.appsflyer;

import android.app.Activity;
import android.app.Application;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.location.Location;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.os.Process;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.appsflyer.AFLogger;
import com.appsflyer.AppsFlyerProperties;
import com.appsflyer.OneLinkHttpTask;
import com.appsflyer.cache.CacheManager;
import com.appsflyer.cache.RequestCacheData;
import com.appsflyer.d;
import com.appsflyer.f;
import com.appsflyer.i;
import com.appsflyer.j;
import com.appsflyer.p;
import com.appsflyer.r;
import com.appsflyer.share.Constants;
import com.appsflyer.x;
import com.baidu.tts.loopj.AsyncHttpResponseHandler;
import com.baidu.tts.loopj.RequestParams;
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.perf.FirebasePerformance;
import com.iflytek.cloud.SpeechConstant;
import com.iflytek.speech.UtilityConfig;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationTargetException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.httpclient.HttpState;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class AppsFlyerLib implements c {
    public static final String AF_PRE_INSTALL_PATH = "AF_PRE_INSTALL_PATH";
    public static final String ATTRIBUTION_ID_COLUMN_NAME = "aid";
    public static final String ATTRIBUTION_ID_CONTENT_URI = "content://com.facebook.katana.provider.AttributionIdProvider";
    public static final String IS_STOP_TRACKING_USED = "is_stop_tracking_used";
    public static final String LOG_TAG = "AppsFlyer_4.8.12";
    public static final String PRE_INSTALL_SYSTEM_DEFAULT = "/data/local/tmp/pre_install.appsflyer";
    public static final String PRE_INSTALL_SYSTEM_DEFAULT_ETC = "/etc/pre_install.appsflyer";
    public static final String PRE_INSTALL_SYSTEM_RO_PROP = "ro.appsflyer.preinstall.path";

    /* renamed from: ʻ  reason: contains not printable characters */
    private static String f15 = new StringBuilder("https://t.%s/api/v").append(f17).toString();

    /* renamed from: ʼ  reason: contains not printable characters */
    private static String f16 = new StringBuilder("https://attr.%s/api/v").append(f17).toString();

    /* renamed from: ʽ  reason: contains not printable characters */
    private static final String f17 = new StringBuilder().append(f23).append("/androidevent?buildnumber=4.8.12&app_id=").toString();

    /* renamed from: ˈ  reason: contains not printable characters */
    private static AppsFlyerLib f18 = new AppsFlyerLib();

    /* renamed from: ˊ  reason: contains not printable characters */
    static AppsFlyerInAppPurchaseValidatorListener f19 = null;

    /* renamed from: ˋॱ  reason: contains not printable characters */
    private static AppsFlyerConversionListener f20 = null;

    /* renamed from: ˎ  reason: contains not printable characters */
    static final String f21 = new StringBuilder("https://register.%s/api/v").append(f17).toString();

    /* renamed from: ˏॱ  reason: contains not printable characters */
    private static final List<String> f22 = Arrays.asList("is_cache");

    /* renamed from: ॱ  reason: contains not printable characters */
    static final String f23 = BuildConfig.AF_SDK_VERSION.substring(0, BuildConfig.AF_SDK_VERSION.indexOf("."));

    /* renamed from: ॱˊ  reason: contains not printable characters */
    private static final List<String> f24 = Arrays.asList("googleplay", "playstore", "googleplaystore");

    /* renamed from: ॱॱ  reason: contains not printable characters */
    private static String f25 = new StringBuilder("https://events.%s/api/v").append(f17).toString();

    /* renamed from: ʻॱ  reason: contains not printable characters */
    private b f26 = null;

    /* renamed from: ʼॱ  reason: contains not printable characters */
    private Uri f27 = null;

    /* renamed from: ʽॱ  reason: contains not printable characters */
    private long f28;

    /* renamed from: ʾ  reason: contains not printable characters */
    private long f29;

    /* renamed from: ʿ  reason: contains not printable characters */
    private r.b f30;

    /* renamed from: ˉ  reason: contains not printable characters */
    private boolean f31 = false;

    /* renamed from: ˊˊ  reason: contains not printable characters */
    private String f32;

    /* renamed from: ˊˋ  reason: contains not printable characters */
    private Map<Long, String> f33;

    /* renamed from: ˊॱ  reason: contains not printable characters */
    private long f34 = TimeUnit.SECONDS.toMillis(5);

    /* renamed from: ˊᐝ  reason: contains not printable characters */
    private boolean f35 = false;

    /* renamed from: ˋ  reason: contains not printable characters */
    String f36;

    /* renamed from: ˋˊ  reason: contains not printable characters */
    private long f37;

    /* renamed from: ˋˋ  reason: contains not printable characters */
    private boolean f38;

    /* renamed from: ˋᐝ  reason: contains not printable characters */
    private boolean f39 = false;

    /* renamed from: ˌ  reason: contains not printable characters */
    private boolean f40;

    /* renamed from: ˍ  reason: contains not printable characters */
    private s f41 = new s();

    /* renamed from: ˎˎ  reason: contains not printable characters */
    private boolean f42 = false;

    /* renamed from: ˏ  reason: contains not printable characters */
    String f43;

    /* renamed from: ͺ  reason: contains not printable characters */
    private long f44 = -1;

    /* renamed from: ॱˋ  reason: contains not printable characters */
    private long f45;

    /* renamed from: ॱˎ  reason: contains not printable characters */
    private boolean f46 = false;

    /* renamed from: ॱᐝ  reason: contains not printable characters */
    private ScheduledExecutorService f47 = null;

    /* renamed from: ᐝ  reason: contains not printable characters */
    private long f48 = -1;

    /* renamed from: ᐝॱ  reason: contains not printable characters */
    private Map<String, String> f49;

    /* access modifiers changed from: package-private */
    /* renamed from: com.appsflyer.AppsFlyerLib$3  reason: invalid class name */
    public static /* synthetic */ class AnonymousClass3 {

        /* renamed from: ॱ  reason: contains not printable characters */
        static final /* synthetic */ int[] f53 = new int[AppsFlyerProperties.EmailsCryptType.values().length];

        static {
            try {
                f53[AppsFlyerProperties.EmailsCryptType.SHA1.ordinal()] = 1;
            } catch (NoSuchFieldError e) {
            }
            try {
                f53[AppsFlyerProperties.EmailsCryptType.MD5.ordinal()] = 2;
            } catch (NoSuchFieldError e2) {
            }
            try {
                f53[AppsFlyerProperties.EmailsCryptType.SHA256.ordinal()] = 3;
            } catch (NoSuchFieldError e3) {
            }
            try {
                f53[AppsFlyerProperties.EmailsCryptType.NONE.ordinal()] = 4;
            } catch (NoSuchFieldError e4) {
            }
        }
    }

    abstract class a implements Runnable {

        /* renamed from: ˊ  reason: contains not printable characters */
        WeakReference<Context> f57 = null;

        /* renamed from: ˎ  reason: contains not printable characters */
        private AtomicInteger f59 = new AtomicInteger(0);

        /* renamed from: ˏ  reason: contains not printable characters */
        private ScheduledExecutorService f60;

        /* renamed from: ॱ  reason: contains not printable characters */
        private String f61;

        a(Context context, String str, ScheduledExecutorService scheduledExecutorService) {
            this.f57 = new WeakReference<>(context);
            this.f61 = str;
            if (scheduledExecutorService == null) {
                this.f60 = AFExecutor.getInstance().m9();
            } else {
                this.f60 = scheduledExecutorService;
            }
        }

        /* JADX WARNING: Removed duplicated region for block: B:56:0x01ef A[Catch:{ all -> 0x0229 }] */
        /* JADX WARNING: Removed duplicated region for block: B:60:0x0205  */
        /* JADX WARNING: Removed duplicated region for block: B:67:0x0231  */
        public void run() {
            HttpURLConnection httpURLConnection;
            Throwable th;
            Map<String, String> map;
            if (this.f61 != null && this.f61.length() != 0 && !AppsFlyerLib.this.isTrackingStopped()) {
                this.f59.incrementAndGet();
                try {
                    Context context = this.f57.get();
                    if (context == null) {
                        this.f59.decrementAndGet();
                        return;
                    }
                    long currentTimeMillis = System.currentTimeMillis();
                    String r3 = AppsFlyerLib.m31(context, AppsFlyerLib.m62(new WeakReference(context)));
                    String str = "";
                    if (r3 != null) {
                        if (!AppsFlyerLib.f24.contains(r3.toLowerCase())) {
                            str = "-".concat(String.valueOf(r3));
                        } else {
                            AFLogger.afWarnLog(String.format("AF detected using redundant Google-Play channel for attribution - %s. Using without channel postfix.", r3));
                        }
                    }
                    StringBuilder append = new StringBuilder().append(m87()).append(context.getPackageName()).append(str).append("?devkey=").append(this.f61).append("&device_id=").append(t.m199(new WeakReference(context)));
                    u.m204().m219(append.toString(), "");
                    f.AnonymousClass4.m125(new StringBuilder("Calling server for attribution url: ").append(append.toString()).toString());
                    httpURLConnection = (HttpURLConnection) new URL(append.toString()).openConnection();
                    try {
                        httpURLConnection.setRequestMethod("GET");
                        httpURLConnection.setConnectTimeout(10000);
                        httpURLConnection.setRequestProperty("Connection", "close");
                        httpURLConnection.connect();
                        int responseCode = httpURLConnection.getResponseCode();
                        String r6 = AppsFlyerLib.m51(httpURLConnection);
                        u.m204().m215(append.toString(), responseCode, r6);
                        if (responseCode == 200) {
                            AppsFlyerLib.m55(context, "appsflyerGetConversionDataTiming", (System.currentTimeMillis() - currentTimeMillis) / 1000);
                            f.AnonymousClass4.m125("Attribution data: ".concat(String.valueOf(r6)));
                            if (r6.length() > 0 && context != null) {
                                Map<String, String> r4 = AppsFlyerLib.m34(r6);
                                String str2 = r4.get("iscache");
                                if (str2 != null && Boolean.toString(false).equals(str2)) {
                                    AppsFlyerLib.m55(context, "appsflyerConversionDataCacheExpiration", System.currentTimeMillis());
                                }
                                if (r4.containsKey(Constants.URL_SITE_ID)) {
                                    if (r4.containsKey("af_channel")) {
                                        AFLogger.afDebugLog(new StringBuilder(Constants.LOG_INVITE_DETECTED_APP_INVITE_VIA_CHANNEL).append(r4.get("af_channel")).toString());
                                    } else {
                                        AFLogger.afDebugLog(String.format(Constants.LOG_CROSS_PROMOTION_APP_INSTALLED_FROM_CROSS_PROMOTION, r4.get(Constants.URL_SITE_ID)));
                                    }
                                }
                                if (r4.containsKey(Constants.URL_SITE_ID)) {
                                    AFLogger.afDebugLog(new StringBuilder(Constants.LOG_INVITE_DETECTED_APP_INVITE_VIA_CHANNEL).append(r4.get("af_channel")).toString());
                                }
                                r4.put("is_first_launch", Boolean.toString(false));
                                String jSONObject = new JSONObject(r4).toString();
                                if (jSONObject != null) {
                                    AppsFlyerLib.m66(context, "attributionId", jSONObject);
                                } else {
                                    AppsFlyerLib.m66(context, "attributionId", r6);
                                }
                                AFLogger.afDebugLog(new StringBuilder("iscache=").append(str2).append(" caching conversion data").toString());
                                if (AppsFlyerLib.f20 != null && this.f59.intValue() <= 1) {
                                    try {
                                        map = AppsFlyerLib.m26(context);
                                    } catch (o e) {
                                        AFLogger.afErrorLog("Exception while trying to fetch attribution data. ", e);
                                        map = r4;
                                    }
                                    m86(map);
                                }
                            }
                        } else {
                            if (AppsFlyerLib.f20 != null) {
                                m85("Error connection to server: ".concat(String.valueOf(responseCode)), responseCode);
                            }
                            f.AnonymousClass4.m125(new StringBuilder("AttributionIdFetcher response code: ").append(responseCode).append("  url: ").append((Object) append).toString());
                        }
                        this.f59.decrementAndGet();
                        if (httpURLConnection != null) {
                            httpURLConnection.disconnect();
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        try {
                            if (AppsFlyerLib.f20 != null) {
                                m85(th.getMessage(), 0);
                            }
                            AFLogger.afErrorLog(th.getMessage(), th);
                            this.f59.decrementAndGet();
                            if (httpURLConnection != null) {
                                httpURLConnection.disconnect();
                            }
                            this.f60.shutdown();
                        } catch (Throwable th3) {
                            th = th3;
                            this.f59.decrementAndGet();
                            if (httpURLConnection != null) {
                                httpURLConnection.disconnect();
                            }
                            throw th;
                        }
                    }
                    this.f60.shutdown();
                } catch (Throwable th4) {
                    th = th4;
                    httpURLConnection = null;
                    this.f59.decrementAndGet();
                    if (httpURLConnection != null) {
                    }
                    throw th;
                }
            }
        }

        /* access modifiers changed from: protected */
        /* renamed from: ˎ  reason: contains not printable characters */
        public abstract void m85(String str, int i);

        /* access modifiers changed from: protected */
        /* renamed from: ˎ  reason: contains not printable characters */
        public abstract void m86(Map<String, String> map);

        /* renamed from: ˏ  reason: contains not printable characters */
        public abstract String m87();
    }

    /* access modifiers changed from: package-private */
    public class b extends a {
        public b(Context context, String str, ScheduledExecutorService scheduledExecutorService) {
            super(context, str, scheduledExecutorService);
        }

        /* access modifiers changed from: protected */
        @Override // com.appsflyer.AppsFlyerLib.a
        /* renamed from: ˎ  reason: contains not printable characters */
        public final void m88(String str, int i) {
            AppsFlyerLib.f20.onInstallConversionFailure(str);
            if (i >= 400 && i < 500) {
                AppsFlyerLib.m65(this.f57.get(), "appsflyerConversionDataRequestRetries", AppsFlyerLib.m59(this.f57.get()).getInt("appsflyerConversionDataRequestRetries", 0) + 1);
            }
        }

        /* access modifiers changed from: protected */
        @Override // com.appsflyer.AppsFlyerLib.a
        /* renamed from: ˎ  reason: contains not printable characters */
        public final void m89(Map<String, String> map) {
            map.put("is_first_launch", Boolean.toString(true));
            AppsFlyerLib.f20.onInstallConversionDataLoaded(map);
            AppsFlyerLib.m65(this.f57.get(), "appsflyerConversionDataRequestRetries", 0);
        }

        @Override // com.appsflyer.AppsFlyerLib.a
        /* renamed from: ˏ  reason: contains not printable characters */
        public final String m90() {
            return ServerConfigHandler.getUrl("https://api.%s/install_data/v3/");
        }
    }

    /* access modifiers changed from: package-private */
    public class c implements Runnable {

        /* renamed from: ˊ  reason: contains not printable characters */
        private WeakReference<Context> f63 = null;

        public c(Context context) {
            this.f63 = new WeakReference<>(context);
        }

        public final void run() {
            if (!AppsFlyerLib.this.f46) {
                AppsFlyerLib.this.f45 = System.currentTimeMillis();
                if (this.f63 != null) {
                    AppsFlyerLib.this.f46 = true;
                    try {
                        String r5 = AppsFlyerLib.m49(AppsFlyerProperties.AF_KEY);
                        synchronized (this.f63) {
                            for (RequestCacheData requestCacheData : CacheManager.getInstance().getCachedRequests(this.f63.get())) {
                                AFLogger.afInfoLog(new StringBuilder("resending request: ").append(requestCacheData.getRequestURL()).toString());
                                try {
                                    AppsFlyerLib.m68(AppsFlyerLib.this, new StringBuilder().append(requestCacheData.getRequestURL()).append("&isCachedRequest=true&timeincache=").append(Long.toString((System.currentTimeMillis() - Long.parseLong(requestCacheData.getCacheKey(), 10)) / 1000)).toString(), requestCacheData.getPostData(), r5, this.f63, requestCacheData.getCacheKey(), false);
                                } catch (Exception e) {
                                    AFLogger.afErrorLog("Failed to resend cached request", e);
                                }
                            }
                        }
                    } catch (Exception e2) {
                        AFLogger.afErrorLog("failed to check cache. ", e2);
                    } finally {
                        AppsFlyerLib.this.f46 = false;
                    }
                    AppsFlyerLib.this.f47.shutdown();
                    AppsFlyerLib.this.f47 = null;
                }
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class d implements Runnable {

        /* renamed from: ʼ  reason: contains not printable characters */
        private boolean f66;

        /* renamed from: ʽ  reason: contains not printable characters */
        private boolean f67;

        /* renamed from: ˊ  reason: contains not printable characters */
        private WeakReference<Context> f68;

        /* renamed from: ˋ  reason: contains not printable characters */
        private String f69;

        /* renamed from: ˎ  reason: contains not printable characters */
        private final Intent f70;

        /* renamed from: ˏ  reason: contains not printable characters */
        private String f71;

        /* renamed from: ॱ  reason: contains not printable characters */
        private String f72;

        /* renamed from: ॱॱ  reason: contains not printable characters */
        private String f73;

        /* renamed from: ᐝ  reason: contains not printable characters */
        private ExecutorService f74;

        /* JADX DEBUG: Multi-variable search result rejected for r8v0, resolved type: boolean */
        /* JADX WARN: Multi-variable type inference failed */
        private d(WeakReference<Context> weakReference, String str, String str2, String str3, String str4, boolean z, boolean z2, Intent intent) {
            this.f68 = weakReference;
            this.f72 = str;
            this.f71 = str2;
            this.f69 = str3;
            this.f73 = str4;
            this.f67 = true;
            this.f74 = z;
            this.f66 = z2;
            this.f70 = intent;
        }

        /* synthetic */ d(AppsFlyerLib appsFlyerLib, WeakReference weakReference, String str, String str2, String str3, String str4, ExecutorService executorService, boolean z, Intent intent, byte b) {
            this(weakReference, str, str2, str3, str4, executorService, z, intent);
        }

        public final void run() {
            AppsFlyerLib.m36(AppsFlyerLib.this, this.f68.get(), this.f72, this.f71, this.f69, this.f73, this.f67, this.f66, this.f70);
        }
    }

    /* access modifiers changed from: package-private */
    public class e implements Runnable {

        /* renamed from: ˊ  reason: contains not printable characters */
        private WeakReference<Context> f76;

        /* renamed from: ˋ  reason: contains not printable characters */
        private Map<String, Object> f77;

        /* renamed from: ˎ  reason: contains not printable characters */
        private int f78;

        /* renamed from: ˏ  reason: contains not printable characters */
        private boolean f79;

        /* renamed from: ॱ  reason: contains not printable characters */
        private String f80;

        private e(String str, Map<String, Object> map, Context context, boolean z, int i) {
            this.f76 = null;
            this.f80 = str;
            this.f77 = map;
            this.f76 = new WeakReference<>(context);
            this.f79 = z;
            this.f78 = i;
        }

        /* synthetic */ e(AppsFlyerLib appsFlyerLib, String str, Map map, Context context, boolean z, int i, byte b) {
            this(str, map, context, z, i);
        }

        public final void run() {
            String str = null;
            if (!AppsFlyerLib.this.isTrackingStopped()) {
                if (this.f79 && this.f78 <= 2 && AppsFlyerLib.m39(AppsFlyerLib.this)) {
                    this.f77.put("rfr", AppsFlyerLib.this.f49);
                }
                try {
                    str = AFHelper.convertToJsonObject(this.f77).toString();
                    AppsFlyerLib.m68(AppsFlyerLib.this, this.f80, str, (String) this.f77.get("appsflyerKey"), this.f76, null, this.f79);
                } catch (IOException e) {
                    AFLogger.afErrorLog("Exception while sending request to server. ", e);
                    if (str != null && this.f76 != null && !this.f80.contains("&isCachedRequest=true&timeincache=")) {
                        CacheManager.getInstance().cacheRequest(new RequestCacheData(this.f80, str, BuildConfig.AF_SDK_VERSION), this.f76.get());
                        AFLogger.afErrorLog(e.getMessage(), e);
                    }
                } catch (Throwable th) {
                    AFLogger.afErrorLog(th.getMessage(), th);
                }
            }
        }
    }

    private AppsFlyerLib() {
        AFVersionDeclaration.init();
    }

    public static AppsFlyerLib getInstance() {
        return f18;
    }

    /* renamed from: ˊ  reason: contains not printable characters */
    private static File m25(String str) {
        if (str != null) {
            try {
                if (str.trim().length() > 0) {
                    return new File(str.trim());
                }
            } catch (Throwable th) {
                AFLogger.afErrorLog(th.getMessage(), th);
            }
        }
        return null;
    }

    /* access modifiers changed from: private */
    /* renamed from: ˊ  reason: contains not printable characters */
    public static Map<String, String> m26(Context context) throws o {
        String string = context.getSharedPreferences("appsflyer-data", 0).getString("attributionId", null);
        if (string != null && string.length() > 0) {
            return m34(string);
        }
        throw new o();
    }

    /* renamed from: ˊ  reason: contains not printable characters */
    private void m28(Application application) {
        AppsFlyerProperties.getInstance().loadProperties(application.getApplicationContext());
        if (Build.VERSION.SDK_INT < 14) {
            AFLogger.afInfoLog("SDK<14 call trackEvent manually");
            AFLogger.afInfoLog("onBecameForeground");
            getInstance().f28 = System.currentTimeMillis();
            getInstance().m75(application, null, null);
            AFLogger.resetDeltaTime();
        } else if (Build.VERSION.SDK_INT >= 14 && this.f30 == null) {
            r.m179();
            this.f30 = new r.b() {
                /* class com.appsflyer.AppsFlyerLib.AnonymousClass4 */

                @Override // com.appsflyer.r.b
                /* renamed from: ˊ  reason: contains not printable characters */
                public final void m83(WeakReference<Context> weakReference) {
                    a.m102(weakReference.get());
                    f r0 = f.m119(weakReference.get());
                    r0.f127.post(r0.f119);
                }

                @Override // com.appsflyer.r.b
                /* renamed from: ˎ  reason: contains not printable characters */
                public final void m84(Activity activity) {
                    if (2 > AppsFlyerLib.m40(AppsFlyerLib.m59(activity))) {
                        f r0 = f.m119(activity);
                        r0.f127.post(r0.f119);
                        r0.f127.post(r0.f120);
                    }
                    AFLogger.afInfoLog("onBecameForeground");
                    AppsFlyerLib.getInstance().m76();
                    AppsFlyerLib.getInstance().m75(activity, null, null);
                    AFLogger.resetDeltaTime();
                }
            };
            r.m177().m180(application, this.f30);
        }
    }

    /* renamed from: ˊ  reason: contains not printable characters */
    private static void m29(Context context, Map<String, ? super String> map) {
        j jVar = j.c.f156;
        j.e r0 = j.m142(context);
        map.put("network", r0.m146());
        if (r0.m145() != null) {
            map.put("operator", r0.m145());
        }
        if (r0.m144() != null) {
            map.put("carrier", r0.m144());
        }
    }

    /* renamed from: ˊ  reason: contains not printable characters */
    private static void m30(ScheduledExecutorService scheduledExecutorService, Runnable runnable, long j, TimeUnit timeUnit) {
        if (scheduledExecutorService != null) {
            try {
                if (!scheduledExecutorService.isShutdown() && !scheduledExecutorService.isTerminated()) {
                    scheduledExecutorService.schedule(runnable, j, timeUnit);
                    return;
                }
            } catch (RejectedExecutionException e2) {
                AFLogger.afErrorLog("scheduleJob failed with RejectedExecutionException Exception", e2);
                return;
            } catch (Throwable th) {
                AFLogger.afErrorLog("scheduleJob failed with Exception", th);
                return;
            }
        }
        AFLogger.afWarnLog("scheduler is null, shut downed or terminated");
    }

    /* access modifiers changed from: private */
    /* renamed from: ˋ  reason: contains not printable characters */
    public static String m31(Context context, String str) throws PackageManager.NameNotFoundException {
        SharedPreferences sharedPreferences = context.getSharedPreferences("appsflyer-data", 0);
        if (sharedPreferences.contains("CACHED_CHANNEL")) {
            return sharedPreferences.getString("CACHED_CHANNEL", null);
        }
        m66(context, "CACHED_CHANNEL", str);
        return str;
    }

    @Nullable
    /* renamed from: ˋ  reason: contains not printable characters */
    private static String m32(WeakReference<Context> weakReference, String str) {
        if (weakReference.get() == null) {
            return null;
        }
        return m50(str, weakReference.get().getPackageManager(), weakReference.get().getPackageName());
    }

    /* access modifiers changed from: private */
    /* renamed from: ˋ  reason: contains not printable characters */
    public static Map<String, String> m34(String str) {
        HashMap hashMap = new HashMap();
        try {
            JSONObject jSONObject = new JSONObject(str);
            Iterator<String> keys = jSONObject.keys();
            while (keys.hasNext()) {
                String next = keys.next();
                if (!f22.contains(next)) {
                    String string = jSONObject.getString(next);
                    if (!TextUtils.isEmpty(string) && !"null".equals(string)) {
                        hashMap.put(next, string);
                    }
                }
            }
            return hashMap;
        } catch (JSONException e2) {
            AFLogger.afErrorLog(e2.getMessage(), e2);
            return null;
        }
    }

    /* renamed from: ˋ  reason: contains not printable characters */
    private void m35(Context context, String str, String str2, String str3, String str4, Intent intent) {
        Context applicationContext = context.getApplicationContext();
        boolean z = str2 == null;
        if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.AF_WAITFOR_CUSTOMERID, false) && AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.APP_USER_ID) == null) {
            AFLogger.afInfoLog("CustomerUserId not set, Tracking is disabled", true);
            return;
        }
        if (z) {
            if (!AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.LAUNCH_PROTECT_ENABLED, true)) {
                AFLogger.afInfoLog("Allowing multiple launches within a 5 second time window.");
            } else if (m70()) {
                return;
            }
            this.f48 = System.currentTimeMillis();
        }
        ScheduledThreadPoolExecutor r7 = AFExecutor.getInstance().m9();
        m30(r7, new d(this, new WeakReference(applicationContext), str, str2, str3, str4, r7, false, intent, (byte) 0), 150, TimeUnit.MILLISECONDS);
    }

    /* renamed from: ˋ  reason: contains not printable characters */
    static /* synthetic */ void m36(AppsFlyerLib appsFlyerLib, Context context, String str, String str2, String str3, String str4, boolean z, boolean z2, Intent intent) {
        if (context == null) {
            AFLogger.afDebugLog("sendTrackingWithEvent - got null context. skipping event/launch.");
            return;
        }
        SharedPreferences sharedPreferences = context.getSharedPreferences("appsflyer-data", 0);
        AppsFlyerProperties.getInstance().saveProperties(sharedPreferences);
        if (!appsFlyerLib.isTrackingStopped()) {
            AFLogger.afInfoLog(new StringBuilder("sendTrackingWithEvent from activity: ").append(context.getClass().getName()).toString());
        }
        boolean z3 = str2 == null;
        Map<String, Object> r6 = appsFlyerLib.m79(context, str, str2, str3, str4, z, sharedPreferences, z3, intent);
        String str5 = (String) r6.get("appsflyerKey");
        if (str5 == null || str5.length() == 0) {
            AFLogger.afDebugLog("Not sending data yet, waiting for dev key");
            return;
        }
        if (!appsFlyerLib.isTrackingStopped()) {
            AFLogger.afInfoLog("AppsFlyerLib.sendTrackingWithEvent");
        }
        String obj = new StringBuilder().append(z3 ? z2 ? ServerConfigHandler.getUrl(f16) : ServerConfigHandler.getUrl(f15) : ServerConfigHandler.getUrl(f25)).append(context.getPackageName()).toString();
        int r9 = m58(sharedPreferences, "appsFlyerCount", false);
        if (!AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.COLLECT_ANDROID_ID_OR_IMEI_FORCE_BY_USER, false) && r6.get(ServerParameters.ADVERTISING_ID_PARAM) != null) {
            try {
                if (TextUtils.isEmpty(appsFlyerLib.f43) && r6.remove("android_id") != null) {
                    AFLogger.afInfoLog("validateGaidAndIMEI :: removing: android_id");
                }
                if (TextUtils.isEmpty(appsFlyerLib.f36) && r6.remove("imei") != null) {
                    AFLogger.afInfoLog("validateGaidAndIMEI :: removing: imei");
                }
            } catch (Exception e2) {
                AFLogger.afErrorLog("failed to remove IMEI or AndroidID key from params; ", e2);
            }
        }
        e eVar = new e(appsFlyerLib, obj, r6, context.getApplicationContext(), z3, r9, (byte) 0);
        if (z3 && m57(context)) {
            if (!(appsFlyerLib.f49 != null && appsFlyerLib.f49.size() > 0)) {
                AFLogger.afDebugLog("Failed to get new referrer, wait ...");
                m30(AFExecutor.getInstance().m9(), eVar, 500, TimeUnit.MILLISECONDS);
                return;
            }
        }
        eVar.run();
    }

    /* renamed from: ˋ  reason: contains not printable characters */
    static /* synthetic */ void m37(Map map) {
        if (f20 != null) {
            try {
                f20.onAppOpenAttribution(map);
            } catch (Throwable th) {
                AFLogger.afErrorLog(th.getLocalizedMessage(), th);
            }
        }
    }

    /* renamed from: ˋ  reason: contains not printable characters */
    private static boolean m38(Context context) {
        try {
            if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == 0) {
                return true;
            }
        } catch (Throwable th) {
            AFLogger.afErrorLog("WARNING:  Google play services is unavailable. ", th);
        }
        try {
            context.getPackageManager().getPackageInfo("com.google.android.gms", 0);
            return true;
        } catch (PackageManager.NameNotFoundException e2) {
            AFLogger.afErrorLog("WARNING:  Google Play Services is unavailable. ", e2);
            return false;
        }
    }

    /* renamed from: ˋ  reason: contains not printable characters */
    static /* synthetic */ boolean m39(AppsFlyerLib appsFlyerLib) {
        return appsFlyerLib.f49 != null && appsFlyerLib.f49.size() > 0;
    }

    /* renamed from: ˎ  reason: contains not printable characters */
    static int m40(SharedPreferences sharedPreferences) {
        return m58(sharedPreferences, "appsFlyerCount", false);
    }

    /* renamed from: ˎ  reason: contains not printable characters */
    private static void m45(Context context, String str, String str2, String str3) {
        if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.IS_MONITOR, false)) {
            Intent intent = new Intent("com.appsflyer.MonitorBroadcast");
            intent.setPackage("com.appsflyer.nightvision");
            intent.putExtra("message", str2);
            intent.putExtra(FirebaseAnalytics.Param.VALUE, str3);
            intent.putExtra("packageName", "true");
            intent.putExtra(Constants.URL_MEDIA_SOURCE, new Integer(Process.myPid()));
            intent.putExtra("eventIdentifier", str);
            intent.putExtra("sdk", BuildConfig.AF_SDK_VERSION);
            context.sendBroadcast(intent);
        }
    }

    /* renamed from: ˎ  reason: contains not printable characters */
    private static void m46(JSONObject jSONObject) {
        ArrayList arrayList = new ArrayList();
        Iterator<String> keys = jSONObject.keys();
        while (keys.hasNext()) {
            try {
                JSONArray jSONArray = new JSONArray((String) jSONObject.get(keys.next()));
                for (int i = 0; i < jSONArray.length(); i++) {
                    arrayList.add(Long.valueOf(jSONArray.getLong(i)));
                }
            } catch (JSONException e2) {
            }
        }
        Collections.sort(arrayList);
        Iterator<String> keys2 = jSONObject.keys();
        String str = null;
        while (keys2.hasNext() && str == null) {
            String next = keys2.next();
            try {
                JSONArray jSONArray2 = new JSONArray((String) jSONObject.get(next));
                int i2 = 0;
                while (true) {
                    if (i2 >= jSONArray2.length()) {
                        break;
                    } else if (jSONArray2.getLong(i2) == ((Long) arrayList.get(0)).longValue() || jSONArray2.getLong(i2) == ((Long) arrayList.get(1)).longValue() || jSONArray2.getLong(i2) == ((Long) arrayList.get(arrayList.size() - 1)).longValue()) {
                        str = null;
                    } else {
                        i2++;
                        str = next;
                    }
                }
            } catch (JSONException e3) {
                str = str;
            }
        }
        if (str != null) {
            jSONObject.remove(str);
        }
    }

    /* renamed from: ˏ  reason: contains not printable characters */
    static /* synthetic */ String m49(String str) {
        return AppsFlyerProperties.getInstance().getString(str);
    }

    @Nullable
    /* renamed from: ˏ  reason: contains not printable characters */
    private static String m50(String str, PackageManager packageManager, String str2) {
        Object obj;
        try {
            Bundle bundle = ((PackageItemInfo) packageManager.getApplicationInfo(str2, 128)).metaData;
            if (bundle == null || (obj = bundle.get(str)) == null) {
                return null;
            }
            return obj.toString();
        } catch (Throwable th) {
            AFLogger.afErrorLog(new StringBuilder("Could not find ").append(str).append(" value in the manifest").toString(), th);
            return null;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:17:0x0049 A[SYNTHETIC, Splitter:B:17:0x0049] */
    /* JADX WARNING: Removed duplicated region for block: B:20:0x004e A[Catch:{ Throwable -> 0x0099 }] */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x0068 A[SYNTHETIC, Splitter:B:30:0x0068] */
    /* JADX WARNING: Removed duplicated region for block: B:33:0x006d A[Catch:{ Throwable -> 0x008c }] */
    @NonNull
    /* renamed from: ˏ  reason: contains not printable characters */
    static String m51(HttpURLConnection httpURLConnection) {
        BufferedReader bufferedReader;
        Throwable th;
        String obj;
        InputStreamReader inputStreamReader = null;
        StringBuilder sb = new StringBuilder();
        try {
            InputStream errorStream = httpURLConnection.getErrorStream();
            if (errorStream == null) {
                errorStream = httpURLConnection.getInputStream();
            }
            InputStreamReader inputStreamReader2 = new InputStreamReader(errorStream);
            try {
                BufferedReader bufferedReader2 = new BufferedReader(inputStreamReader2);
                while (true) {
                    try {
                        String readLine = bufferedReader2.readLine();
                        if (readLine != null) {
                            sb.append(readLine).append('\n');
                        } else {
                            try {
                                break;
                            } catch (Throwable th2) {
                            }
                        }
                    } catch (Throwable th3) {
                        th = th3;
                        inputStreamReader = inputStreamReader2;
                        bufferedReader = bufferedReader2;
                        if (bufferedReader != null) {
                        }
                        if (inputStreamReader != null) {
                        }
                        throw th;
                    }
                }
                bufferedReader2.close();
                inputStreamReader2.close();
            } catch (Throwable th4) {
                th = th4;
                bufferedReader = null;
                inputStreamReader = inputStreamReader2;
                if (bufferedReader != null) {
                    try {
                        bufferedReader.close();
                    } catch (Throwable th5) {
                        throw th;
                    }
                }
                if (inputStreamReader != null) {
                    inputStreamReader.close();
                }
                throw th;
            }
        } catch (Throwable th6) {
            th = th6;
            bufferedReader = null;
            if (bufferedReader != null) {
            }
            if (inputStreamReader != null) {
            }
            throw th;
        }
        obj = sb.toString();
        try {
            new JSONObject(obj);
            return obj;
        } catch (JSONException e2) {
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("string_response", obj);
                return jSONObject.toString();
            } catch (JSONException e3) {
                return new JSONObject().toString();
            }
        }
    }

    /* renamed from: ˏ  reason: contains not printable characters */
    static void m53(Context context, String str) {
        JSONArray jSONArray;
        JSONObject jSONObject;
        AFLogger.afDebugLog("received a new (extra) referrer: ".concat(String.valueOf(str)));
        try {
            long currentTimeMillis = System.currentTimeMillis();
            String string = context.getSharedPreferences("appsflyer-data", 0).getString("extraReferrers", null);
            if (string == null) {
                jSONObject = new JSONObject();
                jSONArray = new JSONArray();
            } else {
                JSONObject jSONObject2 = new JSONObject(string);
                if (jSONObject2.has(str)) {
                    jSONArray = new JSONArray((String) jSONObject2.get(str));
                    jSONObject = jSONObject2;
                } else {
                    jSONArray = new JSONArray();
                    jSONObject = jSONObject2;
                }
            }
            if (((long) jSONArray.length()) < 5) {
                jSONArray.put(currentTimeMillis);
            }
            if (((long) jSONObject.length()) >= 4) {
                m46(jSONObject);
            }
            jSONObject.put(str, jSONArray.toString());
            String jSONObject3 = jSONObject.toString();
            SharedPreferences.Editor edit = context.getSharedPreferences("appsflyer-data", 0).edit();
            edit.putString("extraReferrers", jSONObject3);
            if (Build.VERSION.SDK_INT >= 9) {
                edit.apply();
            } else {
                edit.commit();
            }
        } catch (JSONException e2) {
        } catch (Throwable th) {
            AFLogger.afErrorLog(new StringBuilder("Couldn't save referrer - ").append(str).append(": ").toString(), th);
        }
    }

    /* access modifiers changed from: private */
    /* renamed from: ˏ  reason: contains not printable characters */
    public static void m55(Context context, String str, long j) {
        SharedPreferences.Editor edit = context.getSharedPreferences("appsflyer-data", 0).edit();
        edit.putLong(str, j);
        if (Build.VERSION.SDK_INT >= 9) {
            edit.apply();
        } else {
            edit.commit();
        }
    }

    /* renamed from: ˏ  reason: contains not printable characters */
    private static boolean m57(@NonNull Context context) {
        if (m58(context.getSharedPreferences("appsflyer-data", 0), "appsFlyerCount", false) > 2) {
            AFLogger.afRDLog("Install referrer will not load, the counter > 2, ");
            return false;
        }
        try {
            Class.forName("com.android.installreferrer.api.InstallReferrerClient");
            if (j.e.m143(context, "com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE")) {
                AFLogger.afDebugLog("Install referrer is allowed");
                return true;
            }
            AFLogger.afDebugLog("Install referrer is not allowed");
            return false;
        } catch (ClassNotFoundException e2) {
            AFLogger.afRDLog("Class com.android.installreferrer.api.InstallReferrerClient not found");
            return false;
        } catch (Throwable th) {
            AFLogger.afErrorLog("An error occurred while trying to verify manifest : com.android.installreferrer.api.InstallReferrerClient", th);
            return false;
        }
    }

    /* renamed from: ॱ  reason: contains not printable characters */
    private static int m58(SharedPreferences sharedPreferences, String str, boolean z) {
        int i = sharedPreferences.getInt(str, 0);
        if (z) {
            i++;
            SharedPreferences.Editor edit = sharedPreferences.edit();
            edit.putInt(str, i);
            if (Build.VERSION.SDK_INT >= 9) {
                edit.apply();
            } else {
                edit.commit();
            }
        }
        if (u.m204().m209()) {
            u.m204().m212(String.valueOf(i));
        }
        return i;
    }

    /* renamed from: ॱ  reason: contains not printable characters */
    static SharedPreferences m59(Context context) {
        return context.getSharedPreferences("appsflyer-data", 0);
    }

    /* JADX WARNING: Removed duplicated region for block: B:15:0x003e A[SYNTHETIC, Splitter:B:15:0x003e] */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x0056 A[SYNTHETIC, Splitter:B:24:0x0056] */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x0069 A[SYNTHETIC, Splitter:B:31:0x0069] */
    /* renamed from: ॱ  reason: contains not printable characters */
    private static String m60(File file, String str) {
        FileReader fileReader;
        Throwable th;
        FileReader fileReader2;
        Throwable th2;
        String str2 = null;
        try {
            Properties properties = new Properties();
            fileReader = new FileReader(file);
            try {
                properties.load(fileReader);
                AFLogger.afInfoLog("Found PreInstall property!");
                str2 = properties.getProperty(str);
                try {
                    fileReader.close();
                } catch (Throwable th3) {
                    AFLogger.afErrorLog(th3.getMessage(), th3);
                }
            } catch (FileNotFoundException e2) {
                try {
                    AFLogger.afDebugLog(new StringBuilder("PreInstall file wasn't found: ").append(file.getAbsolutePath()).toString());
                    if (fileReader != null) {
                    }
                    return str2;
                } catch (Throwable th4) {
                    th = th4;
                    if (fileReader != null) {
                    }
                    throw th;
                }
            } catch (Throwable th5) {
                fileReader2 = fileReader;
                th2 = th5;
                try {
                    AFLogger.afErrorLog(th2.getMessage(), th2);
                    if (fileReader2 != null) {
                    }
                    return str2;
                } catch (Throwable th6) {
                    th = th6;
                    fileReader = fileReader2;
                    if (fileReader != null) {
                    }
                    throw th;
                }
            }
        } catch (FileNotFoundException e3) {
            fileReader = null;
            AFLogger.afDebugLog(new StringBuilder("PreInstall file wasn't found: ").append(file.getAbsolutePath()).toString());
            if (fileReader != null) {
                try {
                    fileReader.close();
                } catch (Throwable th7) {
                    AFLogger.afErrorLog(th7.getMessage(), th7);
                }
            }
            return str2;
        } catch (Throwable th8) {
            fileReader = null;
            th = th8;
            if (fileReader != null) {
                try {
                    fileReader.close();
                } catch (Throwable th9) {
                    AFLogger.afErrorLog(th9.getMessage(), th9);
                }
            }
            throw th;
        }
        return str2;
    }

    /* renamed from: ॱ  reason: contains not printable characters */
    private static String m61(String str) {
        try {
            return (String) Class.forName("android.os.SystemProperties").getMethod("get", String.class).invoke(null, str);
        } catch (Throwable th) {
            AFLogger.afErrorLog(th.getMessage(), th);
            return null;
        }
    }

    /* renamed from: ॱ  reason: contains not printable characters */
    static /* synthetic */ String m62(WeakReference weakReference) {
        String string = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.CHANNEL);
        return string == null ? m32(weakReference, "CHANNEL") : string;
    }

    /* renamed from: ॱ  reason: contains not printable characters */
    private static Map<String, String> m63(Context context, String str) {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        String[] split = str.split("&");
        int length = split.length;
        int i = 0;
        boolean z = false;
        while (i < length) {
            String str2 = split[i];
            int indexOf = str2.indexOf("=");
            String substring = indexOf > 0 ? str2.substring(0, indexOf) : str2;
            if (!linkedHashMap.containsKey(substring)) {
                if (substring.equals(Constants.URL_CAMPAIGN)) {
                    substring = FirebaseAnalytics.Param.CAMPAIGN;
                } else if (substring.equals(Constants.URL_MEDIA_SOURCE)) {
                    substring = "media_source";
                } else if (substring.equals("af_prt")) {
                    z = true;
                    substring = "agency";
                }
                linkedHashMap.put(substring, "");
            }
            linkedHashMap.put(substring, (indexOf <= 0 || str2.length() <= indexOf + 1) ? null : str2.substring(indexOf + 1));
            i++;
            z = z;
        }
        try {
            if (!linkedHashMap.containsKey("install_time")) {
                PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
                long j = packageInfo.firstInstallTime;
                simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
                linkedHashMap.put("install_time", simpleDateFormat.format(new Date(j)));
            }
        } catch (Exception e2) {
            AFLogger.afErrorLog("Could not fetch install time. ", e2);
        }
        if (!linkedHashMap.containsKey("af_status")) {
            linkedHashMap.put("af_status", "Non-organic");
        }
        if (z) {
            linkedHashMap.remove("media_source");
        }
        return linkedHashMap;
    }

    /* access modifiers changed from: private */
    /* renamed from: ॱ  reason: contains not printable characters */
    public static void m65(Context context, String str, int i) {
        SharedPreferences.Editor edit = context.getSharedPreferences("appsflyer-data", 0).edit();
        edit.putInt(str, i);
        if (Build.VERSION.SDK_INT >= 9) {
            edit.apply();
        } else {
            edit.commit();
        }
    }

    /* access modifiers changed from: private */
    /* renamed from: ॱ  reason: contains not printable characters */
    public static void m66(Context context, String str, String str2) {
        SharedPreferences.Editor edit = context.getSharedPreferences("appsflyer-data", 0).edit();
        edit.putString(str, str2);
        if (Build.VERSION.SDK_INT >= 9) {
            edit.apply();
        } else {
            edit.commit();
        }
    }

    /* renamed from: ॱ  reason: contains not printable characters */
    private void m67(Context context, Map<String, Object> map, Uri uri) {
        final Map<String, String> hashMap;
        map.put("af_deeplink", uri.toString());
        if (uri.getQueryParameter("af_deeplink") != null) {
            this.f31 = "AppsFlyer_Test".equals(uri.getQueryParameter("media_source")) && Boolean.parseBoolean(uri.getQueryParameter("is_retargeting"));
            hashMap = m63(context, uri.getQuery());
            String path = uri.getPath();
            if (path != null) {
                hashMap.put("path", path);
            }
            String scheme = uri.getScheme();
            if (scheme != null) {
                hashMap.put("scheme", scheme);
            }
            String host = uri.getHost();
            if (host != null) {
                hashMap.put("host", host);
            }
        } else {
            hashMap = new HashMap<>();
            hashMap.put("link", uri.toString());
        }
        final WeakReference weakReference = new WeakReference(context);
        p pVar = new p(uri, this);
        pVar.setConnProvider(new OneLinkHttpTask.HttpsUrlConnectionProvider());
        if (pVar.m166()) {
            pVar.m165(new p.b() {
                /* class com.appsflyer.AppsFlyerLib.AnonymousClass2 */

                /* renamed from: ˎ  reason: contains not printable characters */
                private void m80(Map<String, String> map) {
                    if (weakReference.get() != null) {
                        AppsFlyerLib.m66((Context) weakReference.get(), "deeplinkAttribution", new JSONObject(map).toString());
                    }
                }

                @Override // com.appsflyer.p.b
                /* renamed from: ˊ  reason: contains not printable characters */
                public final void m81(Map<String, String> map) {
                    for (String str : map.keySet()) {
                        hashMap.put(str, map.get(str));
                    }
                    m80(hashMap);
                    AppsFlyerLib.m37(hashMap);
                }

                @Override // com.appsflyer.p.b
                /* renamed from: ॱ  reason: contains not printable characters */
                public final void m82(String str) {
                    if (AppsFlyerLib.f20 != null) {
                        m80(hashMap);
                        AppsFlyerLib.f20.onAttributionFailure(str);
                    }
                }
            });
            AFExecutor.getInstance().getThreadPoolExecutor().execute(pVar);
        } else if (f20 != null) {
            try {
                f20.onAppOpenAttribution(hashMap);
            } catch (Throwable th) {
                AFLogger.afErrorLog(th.getLocalizedMessage(), th);
            }
        }
    }

    /* renamed from: ॱ  reason: contains not printable characters */
    static /* synthetic */ void m68(AppsFlyerLib appsFlyerLib, String str, String str2, String str3, WeakReference weakReference, String str4, boolean z) throws IOException {
        URL url = new URL(str);
        AFLogger.afInfoLog(new StringBuilder("url: ").append(url.toString()).toString());
        f.AnonymousClass4.m125("data: ".concat(String.valueOf(str2)));
        m45((Context) weakReference.get(), LOG_TAG, "EVENT_DATA", str2);
        try {
            appsFlyerLib.m69(url, str2, str3, weakReference, str4, z);
        } catch (IOException e2) {
            AFLogger.afErrorLog("Exception in sendRequestToServer. ", e2);
            if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.USE_HTTP_FALLBACK, false)) {
                appsFlyerLib.m69(new URL(str.replace("https:", "http:")), str2, str3, weakReference, str4, z);
                return;
            }
            AFLogger.afInfoLog(new StringBuilder("failed to send requeset to server. ").append(e2.getLocalizedMessage()).toString());
            m45((Context) weakReference.get(), LOG_TAG, "ERROR", e2.getLocalizedMessage());
            throw e2;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:60:0x0178  */
    /* JADX WARNING: Removed duplicated region for block: B:64:0x017f  */
    /* renamed from: ॱ  reason: contains not printable characters */
    private void m69(URL url, String str, String str2, WeakReference<Context> weakReference, String str3, boolean z) throws IOException {
        HttpURLConnection httpURLConnection;
        OutputStreamWriter outputStreamWriter;
        Throwable th;
        Context context = weakReference.get();
        boolean z2 = z && f20 != null;
        try {
            u.m204().m219(url.toString(), str);
            httpURLConnection = (HttpURLConnection) url.openConnection();
            try {
                httpURLConnection.setRequestMethod(FirebasePerformance.HttpMethod.POST);
                httpURLConnection.setRequestProperty("Content-Length", String.valueOf(str.getBytes().length));
                httpURLConnection.setRequestProperty("Content-Type", RequestParams.APPLICATION_JSON);
                httpURLConnection.setConnectTimeout(10000);
                httpURLConnection.setDoOutput(true);
                try {
                    OutputStreamWriter outputStreamWriter2 = new OutputStreamWriter(httpURLConnection.getOutputStream(), AsyncHttpResponseHandler.DEFAULT_CHARSET);
                    try {
                        outputStreamWriter2.write(str);
                        outputStreamWriter2.close();
                        int responseCode = httpURLConnection.getResponseCode();
                        String r4 = m51(httpURLConnection);
                        u.m204().m215(url.toString(), responseCode, r4);
                        AFLogger.afInfoLog("response code: ".concat(String.valueOf(responseCode)));
                        m45(context, LOG_TAG, "SERVER_RESPONSE_CODE", Integer.toString(responseCode));
                        SharedPreferences sharedPreferences = context.getSharedPreferences("appsflyer-data", 0);
                        if (responseCode == 200) {
                            if (weakReference.get() != null && z) {
                                this.f44 = System.currentTimeMillis();
                            }
                            String string = AppsFlyerProperties.getInstance().getString("afUninstallToken");
                            if (string != null) {
                                AFLogger.afDebugLog("Uninstall Token exists: ".concat(String.valueOf(string)));
                                if (!sharedPreferences.getBoolean("sentRegisterRequestToAF", false)) {
                                    AFLogger.afDebugLog("Resending Uninstall token to AF servers: ".concat(String.valueOf(string)));
                                    x.m222(context, new a(string));
                                }
                            } else if (AppsFlyerProperties.getInstance().getString("gcmProjectNumber") != null) {
                                AFLogger.afDebugLog("GCM Project number exists. Fetching token and sending to AF servers");
                                new x.b(new WeakReference(context)).execute(new Void[0]);
                            }
                            if (this.f27 != null) {
                                this.f27 = null;
                            }
                            if (str3 != null) {
                                CacheManager.getInstance().deleteRequest(str3, context);
                            }
                            if (weakReference.get() != null && str3 == null) {
                                m66(context, "sentSuccessfully", "true");
                                if (!this.f46 && System.currentTimeMillis() - this.f45 >= 15000 && this.f47 == null) {
                                    this.f47 = AFExecutor.getInstance().m9();
                                    m30(this.f47, new c(context), 1, TimeUnit.SECONDS);
                                }
                            }
                            this.f42 = ServerConfigHandler.m100(r4).optBoolean("send_background", false);
                        }
                        int i = sharedPreferences.getInt("appsflyerConversionDataRequestRetries", 0);
                        long j = sharedPreferences.getLong("appsflyerConversionDataCacheExpiration", 0);
                        if (j != 0 && System.currentTimeMillis() - j > 5184000000L) {
                            m66(context, "attributionId", (String) null);
                            m55(context, "appsflyerConversionDataCacheExpiration", 0L);
                        }
                        if (sharedPreferences.getString("attributionId", null) == null && str2 != null && z2 && f20 != null && i <= 5) {
                            ScheduledThreadPoolExecutor r2 = AFExecutor.getInstance().m9();
                            m30(r2, new b(context.getApplicationContext(), str2, r2), 10, TimeUnit.MILLISECONDS);
                        } else if (str2 == null) {
                            AFLogger.afWarnLog("AppsFlyer dev key is missing.");
                        } else if (z2 && f20 != null && sharedPreferences.getString("attributionId", null) != null && m58(sharedPreferences, "appsFlyerCount", false) > 1) {
                            try {
                                Map<String, String> r0 = m26(context);
                                if (r0 != null) {
                                    try {
                                        if (!r0.containsKey("is_first_launch")) {
                                            r0.put("is_first_launch", Boolean.toString(false));
                                        }
                                        f20.onInstallConversionDataLoaded(r0);
                                    } catch (Throwable th2) {
                                        AFLogger.afErrorLog(th2.getLocalizedMessage(), th2);
                                    }
                                }
                            } catch (o e2) {
                                AFLogger.afErrorLog(e2.getMessage(), e2);
                            }
                        }
                        if (httpURLConnection != null) {
                            httpURLConnection.disconnect();
                        }
                    } catch (Throwable th3) {
                        th = th3;
                        outputStreamWriter = outputStreamWriter2;
                        if (outputStreamWriter != null) {
                        }
                        throw th;
                    }
                } catch (Throwable th4) {
                    th = th4;
                    outputStreamWriter = null;
                    if (outputStreamWriter != null) {
                        outputStreamWriter.close();
                    }
                    throw th;
                }
            } catch (Throwable th5) {
                th = th5;
                if (httpURLConnection != null) {
                }
                throw th;
            }
        } catch (Throwable th6) {
            th = th6;
            httpURLConnection = null;
            if (httpURLConnection != null) {
                httpURLConnection.disconnect();
            }
            throw th;
        }
    }

    /* renamed from: ॱ  reason: contains not printable characters */
    private boolean m70() {
        if (this.f48 > 0) {
            long currentTimeMillis = System.currentTimeMillis() - this.f48;
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS Z", Locale.US);
            long j = this.f48;
            simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
            String format = simpleDateFormat.format(new Date(j));
            long j2 = this.f44;
            simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
            String format2 = simpleDateFormat.format(new Date(j2));
            if (currentTimeMillis < this.f34 && !isTrackingStopped()) {
                AFLogger.afInfoLog(String.format(Locale.US, "Last Launch attempt: %s;\nLast successful Launch event: %s;\nThis launch is blocked: %s ms < %s ms", format, format2, Long.valueOf(currentTimeMillis), Long.valueOf(this.f34)));
                return true;
            } else if (!isTrackingStopped()) {
                AFLogger.afInfoLog(String.format(Locale.US, "Last Launch attempt: %s;\nLast successful Launch event: %s;\nSending launch (+%s ms)", format, format2, Long.valueOf(currentTimeMillis)));
            }
        } else if (!isTrackingStopped()) {
            AFLogger.afInfoLog("Sending first launch for this session!");
        }
        return false;
    }

    /* renamed from: ᐝ  reason: contains not printable characters */
    private static float m72(Context context) {
        try {
            Intent registerReceiver = context.getApplicationContext().registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
            int intExtra = registerReceiver.getIntExtra(FirebaseAnalytics.Param.LEVEL, -1);
            int intExtra2 = registerReceiver.getIntExtra("scale", -1);
            if (intExtra == -1 || intExtra2 == -1) {
                return 50.0f;
            }
            return (((float) intExtra) / ((float) intExtra2)) * 100.0f;
        } catch (Throwable th) {
            AFLogger.afErrorLog(th.getMessage(), th);
            return 1.0f;
        }
    }

    public AppsFlyerLib enableLocationCollection(boolean z) {
        this.f35 = z;
        return this;
    }

    public void enableUninstallTracking(String str) {
        u.m204().m213("enableUninstallTracking", str);
        AppsFlyerProperties.getInstance().set("gcmProjectNumber", str);
    }

    public String getAppsFlyerUID(Context context) {
        u.m204().m213("getAppsFlyerUID", new String[0]);
        return t.m199(new WeakReference(context));
    }

    public String getAttributionId(ContentResolver contentResolver) {
        String str = null;
        Cursor query = contentResolver.query(Uri.parse(ATTRIBUTION_ID_CONTENT_URI), new String[]{ATTRIBUTION_ID_COLUMN_NAME}, null, null, null);
        if (query != null) {
            try {
                if (query.moveToFirst()) {
                    str = query.getString(query.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME));
                    if (query != null) {
                        try {
                            query.close();
                        } catch (Exception e2) {
                            AFLogger.afErrorLog(e2.getMessage(), e2);
                        }
                    }
                    return str;
                }
            } catch (Exception e3) {
                AFLogger.afErrorLog("Could not collect cursor attribution. ", e3);
                if (query != null) {
                    try {
                        query.close();
                    } catch (Exception e4) {
                        AFLogger.afErrorLog(e4.getMessage(), e4);
                    }
                }
            } catch (Throwable th) {
                if (query != null) {
                    try {
                        query.close();
                    } catch (Exception e5) {
                        AFLogger.afErrorLog(e5.getMessage(), e5);
                    }
                }
                throw th;
            }
        }
        if (query != null) {
            try {
                query.close();
            } catch (Exception e6) {
                AFLogger.afErrorLog(e6.getMessage(), e6);
            }
        }
        return str;
    }

    /* access modifiers changed from: protected */
    public void getConversionData(Context context, final ConversionDataListener conversionDataListener) {
        f20 = new AppsFlyerConversionListener() {
            /* class com.appsflyer.AppsFlyerLib.AnonymousClass5 */

            @Override // com.appsflyer.AppsFlyerConversionListener
            public final void onAppOpenAttribution(Map<String, String> map) {
            }

            @Override // com.appsflyer.AppsFlyerConversionListener
            public final void onAttributionFailure(String str) {
            }

            @Override // com.appsflyer.AppsFlyerConversionListener
            public final void onInstallConversionDataLoaded(Map<String, String> map) {
                conversionDataListener.onConversionDataLoaded(map);
            }

            @Override // com.appsflyer.AppsFlyerConversionListener
            public final void onInstallConversionFailure(String str) {
                conversionDataListener.onConversionFailure(str);
            }
        };
    }

    public String getHost() {
        String string = AppsFlyerProperties.getInstance().getString("custom_host");
        return string != null ? string : ServerParameters.DEFAULT_HOST;
    }

    public String getSdkVersion() {
        u.m204().m213("getSdkVersion", new String[0]);
        return "version: 4.8.12 (build 386)";
    }

    public AppsFlyerLib init(String str, AppsFlyerConversionListener appsFlyerConversionListener) {
        u r1 = u.m204();
        String[] strArr = new String[2];
        strArr[0] = str;
        strArr[1] = appsFlyerConversionListener == null ? "null" : "conversionDataListener";
        r1.m213("init", strArr);
        AFLogger.m20(String.format("Initializing AppsFlyer SDK: (v%s.%s)", BuildConfig.AF_SDK_VERSION, "386"));
        this.f38 = true;
        AppsFlyerProperties.getInstance().set(AppsFlyerProperties.AF_KEY, str);
        f.AnonymousClass4.m124(str);
        f20 = appsFlyerConversionListener;
        return this;
    }

    public AppsFlyerLib init(String str, AppsFlyerConversionListener appsFlyerConversionListener, Context context) {
        if (context != null && m57(context)) {
            if (this.f26 == null) {
                this.f26 = new b();
                this.f26.m106(context, this);
            } else {
                AFLogger.afWarnLog("AFInstallReferrer instance already created");
            }
        }
        return init(str, appsFlyerConversionListener);
    }

    public boolean isPreInstalledApp(Context context) {
        try {
            return (context.getPackageManager().getApplicationInfo(context.getPackageName(), 0).flags & 1) != 0;
        } catch (PackageManager.NameNotFoundException e2) {
            AFLogger.afErrorLog("Could not check if app is pre installed", e2);
            return false;
        }
    }

    public boolean isTrackingStopped() {
        return this.f39;
    }

    @Override // com.appsflyer.c
    public void onHandleReferrer(Map<String, String> map) {
        this.f49 = map;
    }

    public void onPause(Context context) {
        a.m102(context);
        f r0 = f.m119(context);
        r0.f127.post(r0.f119);
    }

    public void registerConversionListener(Context context, AppsFlyerConversionListener appsFlyerConversionListener) {
        u.m204().m213("registerConversionListener", new String[0]);
        if (appsFlyerConversionListener != null) {
            f20 = appsFlyerConversionListener;
        }
    }

    public void registerValidatorListener(Context context, AppsFlyerInAppPurchaseValidatorListener appsFlyerInAppPurchaseValidatorListener) {
        u.m204().m213("registerValidatorListener", new String[0]);
        AFLogger.afDebugLog("registerValidatorListener called");
        if (appsFlyerInAppPurchaseValidatorListener == null) {
            AFLogger.afDebugLog("registerValidatorListener null listener");
        } else {
            f19 = appsFlyerInAppPurchaseValidatorListener;
        }
    }

    public void reportTrackSession(Context context) {
        u.m204().m213("reportTrackSession", new String[0]);
        u.m204().m210();
        m75(context, null, null);
    }

    public void sendDeepLinkData(Activity activity) {
        if (activity != null && activity.getIntent() != null) {
            u.m204().m213("sendDeepLinkData", activity.getLocalClassName(), new StringBuilder("activity_intent_").append(activity.getIntent().toString()).toString());
        } else if (activity != null) {
            u.m204().m213("sendDeepLinkData", activity.getLocalClassName(), "activity_intent_null");
        } else {
            u.m204().m213("sendDeepLinkData", "activity_null");
        }
        AFLogger.afInfoLog(new StringBuilder("getDeepLinkData with activity ").append(activity.getIntent().getDataString()).toString());
        m28(activity.getApplication());
    }

    /* JADX WARNING: Removed duplicated region for block: B:22:0x009b  */
    public void sendPushNotificationData(Activity activity) {
        String str;
        long j;
        Intent intent;
        Bundle extras;
        if (activity != null && activity.getIntent() != null) {
            u.m204().m213("sendPushNotificationData", activity.getLocalClassName(), new StringBuilder("activity_intent_").append(activity.getIntent().toString()).toString());
        } else if (activity != null) {
            u.m204().m213("sendPushNotificationData", activity.getLocalClassName(), "activity_intent_null");
        } else {
            u.m204().m213("sendPushNotificationData", "activity_null");
        }
        if (!(activity instanceof Activity) || (intent = activity.getIntent()) == null || (extras = intent.getExtras()) == null) {
            str = null;
        } else {
            String string = extras.getString("af");
            if (string != null) {
                AFLogger.afInfoLog("Push Notification received af payload = ".concat(String.valueOf(string)));
                extras.remove("af");
                activity.setIntent(intent.putExtras(extras));
            }
            str = string;
        }
        this.f32 = str;
        if (this.f32 != null) {
            long currentTimeMillis = System.currentTimeMillis();
            if (this.f33 == null) {
                AFLogger.afInfoLog("pushes: initializing pushes history..");
                this.f33 = new ConcurrentHashMap();
                j = currentTimeMillis;
            } else {
                try {
                    long j2 = AppsFlyerProperties.getInstance().getLong("pushPayloadMaxAging", 1800000);
                    j = currentTimeMillis;
                    for (Long l : this.f33.keySet()) {
                        try {
                            JSONObject jSONObject = new JSONObject(this.f32);
                            JSONObject jSONObject2 = new JSONObject(this.f33.get(l));
                            if (jSONObject.get(Constants.URL_MEDIA_SOURCE).equals(jSONObject2.get(Constants.URL_MEDIA_SOURCE))) {
                                AFLogger.afInfoLog(new StringBuilder("PushNotificationMeasurement: A previous payload with same PID was already acknowledged! (old: ").append(jSONObject2).append(", new: ").append(jSONObject).append(")").toString());
                                this.f32 = null;
                                return;
                            }
                            if (currentTimeMillis - l.longValue() > j2) {
                                this.f33.remove(l);
                            }
                            j = l.longValue() <= j ? l.longValue() : j;
                        } catch (Throwable th) {
                            th = th;
                            AFLogger.afErrorLog(new StringBuilder("Error while handling push notification measurement: ").append(th.getClass().getSimpleName()).toString(), th);
                            if (this.f33.size() == AppsFlyerProperties.getInstance().getInt("pushPayloadHistorySize", 2)) {
                            }
                            this.f33.put(Long.valueOf(currentTimeMillis), this.f32);
                            m28(activity.getApplication());
                        }
                    }
                } catch (Throwable th2) {
                    th = th2;
                    j = currentTimeMillis;
                    AFLogger.afErrorLog(new StringBuilder("Error while handling push notification measurement: ").append(th.getClass().getSimpleName()).toString(), th);
                    if (this.f33.size() == AppsFlyerProperties.getInstance().getInt("pushPayloadHistorySize", 2)) {
                    }
                    this.f33.put(Long.valueOf(currentTimeMillis), this.f32);
                    m28(activity.getApplication());
                }
            }
            if (this.f33.size() == AppsFlyerProperties.getInstance().getInt("pushPayloadHistorySize", 2)) {
                AFLogger.afInfoLog(new StringBuilder("pushes: removing oldest overflowing push (oldest push:").append(j).append(")").toString());
                this.f33.remove(Long.valueOf(j));
            }
            this.f33.put(Long.valueOf(currentTimeMillis), this.f32);
            m28(activity.getApplication());
        }
    }

    public void setAdditionalData(HashMap<String, Object> hashMap) {
        if (hashMap != null) {
            u.m204().m213("setAdditionalData", hashMap.toString());
            AppsFlyerProperties.getInstance().setCustomData(new JSONObject(hashMap).toString());
        }
    }

    public void setAndroidIdData(String str) {
        u.m204().m213("setAndroidIdData", str);
        this.f43 = str;
    }

    public void setAppId(String str) {
        u.m204().m213("setAppId", str);
        AppsFlyerProperties.getInstance().set("appid", str);
    }

    public void setAppInviteOneLink(String str) {
        u.m204().m213("setAppInviteOneLink", str);
        AFLogger.afInfoLog("setAppInviteOneLink = ".concat(String.valueOf(str)));
        if (str == null || !str.equals(AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.ONELINK_ID))) {
            AppsFlyerProperties.getInstance().remove(AppsFlyerProperties.ONELINK_DOMAIN);
            AppsFlyerProperties.getInstance().remove("onelinkVersion");
            AppsFlyerProperties.getInstance().remove(AppsFlyerProperties.ONELINK_SCHEME);
        }
        AppsFlyerProperties.getInstance().set(AppsFlyerProperties.ONELINK_ID, str);
    }

    @Deprecated
    public void setAppUserId(String str) {
        u.m204().m213("setAppUserId", str);
        setCustomerUserId(str);
    }

    public void setCollectAndroidID(boolean z) {
        u.m204().m213("setCollectAndroidID", String.valueOf(z));
        AppsFlyerProperties.getInstance().set(AppsFlyerProperties.COLLECT_ANDROID_ID, Boolean.toString(z));
        if (z) {
            AppsFlyerProperties.getInstance().set(AppsFlyerProperties.COLLECT_ANDROID_ID_OR_IMEI_FORCE_BY_USER, Boolean.toString(true));
        }
    }

    @Deprecated
    public void setCollectFingerPrint(boolean z) {
        u.m204().m213("setCollectFingerPrint", String.valueOf(z));
        AppsFlyerProperties.getInstance().set(AppsFlyerProperties.COLLECT_FINGER_PRINT, Boolean.toString(z));
    }

    public void setCollectIMEI(boolean z) {
        u.m204().m213("setCollectIMEI", String.valueOf(z));
        AppsFlyerProperties.getInstance().set(AppsFlyerProperties.COLLECT_IMEI, Boolean.toString(z));
        if (z) {
            AppsFlyerProperties.getInstance().set(AppsFlyerProperties.COLLECT_ANDROID_ID_OR_IMEI_FORCE_BY_USER, Boolean.toString(true));
        }
    }

    public void setCurrencyCode(String str) {
        u.m204().m213("setCurrencyCode", str);
        AppsFlyerProperties.getInstance().set(AppsFlyerProperties.CURRENCY_CODE, str);
    }

    public void setCustomerIdAndTrack(String str, @NonNull Context context) {
        boolean z = false;
        if (context != null) {
            if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.AF_WAITFOR_CUSTOMERID, false) && AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.APP_USER_ID) == null) {
                z = true;
            }
            if (z) {
                setCustomerUserId(str);
                AFLogger.afInfoLog(new StringBuilder("CustomerUserId set: ").append(str).append(" - Initializing AppsFlyer Tacking").toString(), true);
                String referrer = AppsFlyerProperties.getInstance().getReferrer(context);
                String string = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.AF_KEY);
                if (referrer == null) {
                    referrer = "";
                }
                m35(context, string, null, null, referrer, context instanceof Activity ? ((Activity) context).getIntent() : null);
                if (AppsFlyerProperties.getInstance().getString("afUninstallToken") != null) {
                    m74(context, AppsFlyerProperties.getInstance().getString("afUninstallToken"));
                    return;
                }
                return;
            }
            setCustomerUserId(str);
            AFLogger.afInfoLog("waitForCustomerUserId is false; setting CustomerUserID: ".concat(String.valueOf(str)), true);
        }
    }

    public void setCustomerUserId(String str) {
        u.m204().m213("setCustomerUserId", str);
        AFLogger.afInfoLog("setCustomerUserId = ".concat(String.valueOf(str)));
        AppsFlyerProperties.getInstance().set(AppsFlyerProperties.APP_USER_ID, str);
    }

    public void setDebugLog(boolean z) {
        u.m204().m213("setDebugLog", String.valueOf(z));
        AppsFlyerProperties.getInstance().set("shouldLog", z);
        AppsFlyerProperties.getInstance().set("logLevel", (z ? AFLogger.LogLevel.DEBUG : AFLogger.LogLevel.NONE).getLevel());
    }

    /* access modifiers changed from: protected */
    public void setDeepLinkData(Intent intent) {
        if (intent != null) {
            try {
                if ("android.intent.action.VIEW".equals(intent.getAction())) {
                    this.f27 = intent.getData();
                    AFLogger.afDebugLog(new StringBuilder("Unity setDeepLinkData = ").append(this.f27).toString());
                }
            } catch (Throwable th) {
                AFLogger.afErrorLog("Exception while setting deeplink data (unity). ", th);
            }
        }
    }

    public void setDeviceTrackingDisabled(boolean z) {
        u.m204().m213("setDeviceTrackingDisabled", String.valueOf(z));
        AppsFlyerProperties.getInstance().set(AppsFlyerProperties.DEVICE_TRACKING_DISABLED, z);
    }

    public void setExtension(String str) {
        u.m204().m213("setExtension", str);
        AppsFlyerProperties.getInstance().set(AppsFlyerProperties.EXTENSION, str);
    }

    @Deprecated
    public void setGCMProjectID(String str) {
        u.m204().m213("setGCMProjectID", str);
        AFLogger.afWarnLog("Method 'setGCMProjectNumber' is deprecated. Please follow the documentation.");
        enableUninstallTracking(str);
    }

    @Deprecated
    public void setGCMProjectNumber(Context context, String str) {
        u.m204().m213("setGCMProjectNumber", str);
        AFLogger.afWarnLog("Method 'setGCMProjectNumber' is deprecated. Please use 'enableUninstallTracking'.");
        enableUninstallTracking(str);
    }

    @Deprecated
    public void setGCMProjectNumber(String str) {
        u.m204().m213("setGCMProjectNumber", str);
        AFLogger.afWarnLog("Method 'setGCMProjectNumber' is deprecated. Please follow the documentation.");
        enableUninstallTracking(str);
    }

    public void setHostName(String str) {
        AppsFlyerProperties.getInstance().set("custom_host", str);
    }

    public void setImeiData(String str) {
        u.m204().m213("setImeiData", str);
        this.f36 = str;
    }

    public void setIsUpdate(boolean z) {
        u.m204().m213("setIsUpdate", String.valueOf(z));
        AppsFlyerProperties.getInstance().set(AppsFlyerProperties.IS_UPDATE, z);
    }

    public void setLogLevel(AFLogger.LogLevel logLevel) {
        AppsFlyerProperties.getInstance().set("logLevel", logLevel.getLevel());
    }

    public void setMinTimeBetweenSessions(int i) {
        this.f34 = TimeUnit.SECONDS.toMillis((long) i);
    }

    public void setPreinstallAttribution(String str, String str2, String str3) {
        AFLogger.afDebugLog("setPreinstallAttribution API called");
        JSONObject jSONObject = new JSONObject();
        if (str != null) {
            try {
                jSONObject.put(Constants.URL_MEDIA_SOURCE, str);
            } catch (JSONException e2) {
                AFLogger.afErrorLog(e2.getMessage(), e2);
            }
        }
        if (str2 != null) {
            jSONObject.put(Constants.URL_CAMPAIGN, str2);
        }
        if (str3 != null) {
            jSONObject.put(Constants.URL_SITE_ID, str3);
        }
        if (jSONObject.has(Constants.URL_MEDIA_SOURCE)) {
            AppsFlyerProperties.getInstance().set("preInstallName", jSONObject.toString());
            return;
        }
        AFLogger.afWarnLog("Cannot set preinstall attribution data without a media source");
    }

    @Deprecated
    public void setUserEmail(String str) {
        u.m204().m213("setUserEmail", str);
        AppsFlyerProperties.getInstance().set(AppsFlyerProperties.USER_EMAIL, str);
    }

    public void setUserEmails(AppsFlyerProperties.EmailsCryptType emailsCryptType, String... strArr) {
        ArrayList arrayList = new ArrayList(strArr.length + 1);
        arrayList.add(emailsCryptType.toString());
        arrayList.addAll(Arrays.asList(strArr));
        u.m204().m213("setUserEmails", (String[]) arrayList.toArray(new String[(strArr.length + 1)]));
        AppsFlyerProperties.getInstance().set(AppsFlyerProperties.EMAIL_CRYPT_TYPE, emailsCryptType.getValue());
        HashMap hashMap = new HashMap();
        ArrayList arrayList2 = new ArrayList();
        String str = null;
        for (String str2 : strArr) {
            switch (AnonymousClass3.f53[emailsCryptType.ordinal()]) {
                case 2:
                    str = "md5_el_arr";
                    arrayList2.add(q.m170(str2));
                    break;
                case 3:
                    str = "sha256_el_arr";
                    arrayList2.add(q.m171(str2));
                    break;
                case 4:
                    str = "plain_el_arr";
                    arrayList2.add(str2);
                    break;
                default:
                    str = "sha1_el_arr";
                    arrayList2.add(q.m172(str2));
                    break;
            }
        }
        hashMap.put(str, arrayList2);
        AppsFlyerProperties.getInstance().setUserEmails(new JSONObject(hashMap).toString());
    }

    public void setUserEmails(String... strArr) {
        u.m204().m213("setUserEmails", strArr);
        setUserEmails(AppsFlyerProperties.EmailsCryptType.NONE, strArr);
    }

    public void startTracking(Application application) {
        if (!this.f38) {
            AFLogger.afWarnLog("ERROR: AppsFlyer SDK is not initialized! The API call 'startTracking(Application)' must be called after the 'init(String, AppsFlyerConversionListener)' API method, which should be called on the Application's onCreate.");
        } else {
            startTracking(application, null);
        }
    }

    public void startTracking(Application application, String str) {
        u.m204().m213("startTracking", str);
        AFLogger.afInfoLog(String.format("Starting AppsFlyer Tracking: (v%s.%s)", BuildConfig.AF_SDK_VERSION, "386"));
        AFLogger.afInfoLog("Build Number: 386");
        AppsFlyerProperties.getInstance().loadProperties(application.getApplicationContext());
        if (!TextUtils.isEmpty(str)) {
            AppsFlyerProperties.getInstance().set(AppsFlyerProperties.AF_KEY, str);
            f.AnonymousClass4.m124(str);
        } else if (TextUtils.isEmpty(AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.AF_KEY))) {
            AFLogger.afWarnLog("ERROR: AppsFlyer SDK is not initialized! You must provide AppsFlyer Dev-Key either in the 'init' API method (should be called on Application's onCreate),or in the startTracking API method (should be called on Activity's onCreate).");
            return;
        }
        m28(application);
    }

    public void stopTracking(boolean z, Context context) {
        this.f39 = z;
        CacheManager.getInstance().clearCache(context);
        if (this.f39) {
            SharedPreferences.Editor edit = context.getSharedPreferences("appsflyer-data", 0).edit();
            edit.putBoolean(IS_STOP_TRACKING_USED, true);
            if (Build.VERSION.SDK_INT >= 9) {
                edit.apply();
            } else {
                edit.commit();
            }
        }
    }

    public void trackAppLaunch(Context context, String str) {
        if (m57(context)) {
            if (this.f26 == null) {
                this.f26 = new b();
                this.f26.m106(context, this);
            } else {
                AFLogger.afWarnLog("AFInstallReferrer instance already created");
            }
        }
        m35(context, str, null, null, "", null);
    }

    public void trackEvent(Context context, String str, Map<String, Object> map) {
        u.m204().m213("trackEvent", str, new JSONObject(map == null ? new HashMap<>() : map).toString());
        m75(context, str, map);
    }

    public void trackLocation(Context context, double d2, double d3) {
        u.m204().m213("trackLocation", String.valueOf(d2), String.valueOf(d3));
        HashMap hashMap = new HashMap();
        hashMap.put(AFInAppEventParameterName.LONGTITUDE, Double.toString(d3));
        hashMap.put(AFInAppEventParameterName.LATITUDE, Double.toString(d2));
        m75(context, AFInAppEventType.LOCATION_COORDINATES, hashMap);
    }

    public void unregisterConversionListener() {
        u.m204().m213("unregisterConversionListener", new String[0]);
        f20 = null;
    }

    public void updateServerUninstallToken(Context context, String str) {
        if (str != null) {
            x.m222(context, new a(str));
        }
    }

    public void validateAndTrackInAppPurchase(Context context, String str, String str2, String str3, String str4, String str5, Map<String, String> map) {
        u r3 = u.m204();
        String[] strArr = new String[6];
        strArr[0] = str;
        strArr[1] = str2;
        strArr[2] = str3;
        strArr[3] = str4;
        strArr[4] = str5;
        strArr[5] = map == null ? "" : map.toString();
        r3.m213("validateAndTrackInAppPurchase", strArr);
        if (!isTrackingStopped()) {
            AFLogger.afInfoLog(new StringBuilder("Validate in app called with parameters: ").append(str3).append(MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR).append(str4).append(MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR).append(str5).toString());
        }
        if (str != null && str4 != null && str2 != null && str5 != null && str3 != null) {
            ScheduledThreadPoolExecutor r11 = AFExecutor.getInstance().m9();
            m30(r11, new h(context.getApplicationContext(), AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.AF_KEY), str, str2, str3, str4, str5, map, r11, context instanceof Activity ? ((Activity) context).getIntent() : null), 10, TimeUnit.MILLISECONDS);
        } else if (f19 != null) {
            f19.onValidateInAppFailure("Please provide purchase parameters");
        }
    }

    public void waitForCustomerUserId(boolean z) {
        AFLogger.afInfoLog("initAfterCustomerUserID: ".concat(String.valueOf(z)), true);
        AppsFlyerProperties.getInstance().set(AppsFlyerProperties.AF_WAITFOR_CUSTOMERID, z);
    }

    /* access modifiers changed from: package-private */
    /* renamed from: ˊ  reason: contains not printable characters */
    public final void m73() {
        this.f29 = System.currentTimeMillis();
    }

    /* access modifiers changed from: package-private */
    /* renamed from: ˊ  reason: contains not printable characters */
    public final void m74(Context context, String str) {
        if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.AF_WAITFOR_CUSTOMERID, false) && AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.APP_USER_ID) == null) {
            AFLogger.afInfoLog("CustomerUserId not set, Tracking is disabled", true);
            return;
        }
        HashMap hashMap = new HashMap();
        String string = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.AF_KEY);
        if (string == null) {
            AFLogger.afWarnLog("[registerUninstall] AppsFlyer's SDK cannot send any event without providing DevKey.");
            return;
        }
        PackageManager packageManager = context.getPackageManager();
        String packageName = context.getPackageName();
        try {
            PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0);
            hashMap.put("app_version_code", Integer.toString(packageInfo.versionCode));
            hashMap.put("app_version_name", packageInfo.versionName);
            hashMap.put("app_name", packageManager.getApplicationLabel(packageInfo.applicationInfo).toString());
            long j = packageInfo.firstInstallTime;
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd_HHmmssZ", Locale.US);
            simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
            hashMap.put("installDate", simpleDateFormat.format(new Date(j)));
        } catch (Throwable th) {
            AFLogger.afErrorLog("Exception while collecting application version info.", th);
        }
        m29(context, hashMap);
        String string2 = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.APP_USER_ID);
        if (string2 != null) {
            hashMap.put("appUserId", string2);
        }
        try {
            hashMap.put("model", Build.MODEL);
            hashMap.put("brand", Build.BRAND);
        } catch (Throwable th2) {
            AFLogger.afErrorLog("Exception while collecting device brand and model.", th2);
        }
        if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.DEVICE_TRACKING_DISABLED, false)) {
            hashMap.put(AppsFlyerProperties.DEVICE_TRACKING_DISABLED, "true");
        }
        k r0 = l.m149(context.getContentResolver());
        if (r0 != null) {
            hashMap.put("amazon_aid", r0.m147());
            hashMap.put("amazon_aid_limit", String.valueOf(r0.m148()));
        }
        String string3 = AppsFlyerProperties.getInstance().getString(ServerParameters.ADVERTISING_ID_PARAM);
        if (string3 != null) {
            hashMap.put(ServerParameters.ADVERTISING_ID_PARAM, string3);
        }
        hashMap.put("devkey", string);
        hashMap.put("uid", t.m199(new WeakReference(context)));
        hashMap.put("af_gcm_token", str);
        hashMap.put("launch_counter", Integer.toString(m58(context.getSharedPreferences("appsflyer-data", 0), "appsFlyerCount", false)));
        hashMap.put("sdk", Integer.toString(Build.VERSION.SDK_INT));
        WeakReference weakReference = new WeakReference(context);
        String string4 = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.CHANNEL);
        if (string4 == null) {
            string4 = m32(weakReference, "CHANNEL");
        }
        if (string4 != null) {
            hashMap.put(AppsFlyerProperties.CHANNEL, string4);
        }
        try {
            n nVar = new n(context, isTrackingStopped());
            nVar.f179 = hashMap;
            nVar.execute(new StringBuilder().append(ServerConfigHandler.getUrl(f21)).append(packageName).toString());
        } catch (Throwable th3) {
            AFLogger.afErrorLog(th3.getMessage(), th3);
        }
    }

    /* access modifiers changed from: package-private */
    /* renamed from: ˋ  reason: contains not printable characters */
    public final void m75(Context context, String str, Map<String, Object> map) {
        Intent intent = context instanceof Activity ? ((Activity) context).getIntent() : null;
        if (AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.AF_KEY) == null) {
            AFLogger.afWarnLog("[TrackEvent/Launch] AppsFlyer's SDK cannot send any event without providing DevKey.");
            return;
        }
        if (map == null) {
            map = new HashMap<>();
        }
        JSONObject jSONObject = new JSONObject(map);
        String referrer = AppsFlyerProperties.getInstance().getReferrer(context);
        String jSONObject2 = jSONObject.toString();
        if (referrer == null) {
            referrer = "";
        }
        m35(context, null, str, jSONObject2, referrer, intent);
    }

    /* access modifiers changed from: package-private */
    /* renamed from: ˎ  reason: contains not printable characters */
    public final void m76() {
        this.f28 = System.currentTimeMillis();
    }

    /* access modifiers changed from: package-private */
    /* renamed from: ˎ  reason: contains not printable characters */
    public final void m77(Context context, Intent intent) {
        String stringExtra = intent.getStringExtra(AppsFlyerProperties.IS_MONITOR);
        if (stringExtra != null) {
            AFLogger.afInfoLog("Turning on monitoring.");
            AppsFlyerProperties.getInstance().set(AppsFlyerProperties.IS_MONITOR, stringExtra.equals("true"));
            m45(context, null, "START_TRACKING", context.getPackageName());
            return;
        }
        AFLogger.afInfoLog("****** onReceive called *******");
        AppsFlyerProperties.getInstance().setOnReceiveCalled();
        String stringExtra2 = intent.getStringExtra("referrer");
        AFLogger.afInfoLog("Play store referrer: ".concat(String.valueOf(stringExtra2)));
        if (stringExtra2 != null) {
            if ("AppsFlyer_Test".equals(intent.getStringExtra("TestIntegrationMode"))) {
                SharedPreferences.Editor edit = context.getSharedPreferences("appsflyer-data", 0).edit();
                edit.clear();
                if (Build.VERSION.SDK_INT >= 9) {
                    edit.apply();
                } else {
                    edit.commit();
                }
                AppsFlyerProperties.getInstance().setFirstLaunchCalled(false);
                AFLogger.afInfoLog("Test mode started..");
                this.f37 = System.currentTimeMillis();
            }
            SharedPreferences.Editor edit2 = context.getSharedPreferences("appsflyer-data", 0).edit();
            edit2.putString("referrer", stringExtra2);
            if (Build.VERSION.SDK_INT >= 9) {
                edit2.apply();
            } else {
                edit2.commit();
            }
            AppsFlyerProperties.getInstance().setReferrer(stringExtra2);
            if (AppsFlyerProperties.getInstance().isFirstLaunchCalled()) {
                AFLogger.afInfoLog("onReceive: isLaunchCalled");
                if (stringExtra2 != null && stringExtra2.length() > 5) {
                    ScheduledThreadPoolExecutor r7 = AFExecutor.getInstance().m9();
                    m30(r7, new d(this, new WeakReference(context.getApplicationContext()), null, null, null, stringExtra2, r7, true, intent, (byte) 0), 5, TimeUnit.MILLISECONDS);
                }
            }
        }
    }

    /* access modifiers changed from: package-private */
    /* renamed from: ˎ  reason: contains not printable characters */
    public final void m78(WeakReference<Context> weakReference) {
        if (weakReference.get() != null) {
            AFLogger.afInfoLog("app went to background");
            SharedPreferences sharedPreferences = weakReference.get().getSharedPreferences("appsflyer-data", 0);
            AppsFlyerProperties.getInstance().saveProperties(sharedPreferences);
            long j = this.f29 - this.f28;
            HashMap hashMap = new HashMap();
            String string = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.AF_KEY);
            if (string == null) {
                AFLogger.afWarnLog("[callStats] AppsFlyer's SDK cannot send any event without providing DevKey.");
                return;
            }
            String string2 = AppsFlyerProperties.getInstance().getString("KSAppsFlyerId");
            if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.DEVICE_TRACKING_DISABLED, false)) {
                hashMap.put(AppsFlyerProperties.DEVICE_TRACKING_DISABLED, "true");
            }
            k r0 = l.m149(weakReference.get().getContentResolver());
            if (r0 != null) {
                hashMap.put("amazon_aid", r0.m147());
                hashMap.put("amazon_aid_limit", String.valueOf(r0.m148()));
            }
            String string3 = AppsFlyerProperties.getInstance().getString(ServerParameters.ADVERTISING_ID_PARAM);
            if (string3 != null) {
                hashMap.put(ServerParameters.ADVERTISING_ID_PARAM, string3);
            }
            hashMap.put("app_id", weakReference.get().getPackageName());
            hashMap.put("devkey", string);
            hashMap.put("uid", t.m199(weakReference));
            hashMap.put("time_in_app", String.valueOf(j / 1000));
            hashMap.put("statType", "user_closed_app");
            hashMap.put("platform", "Android");
            hashMap.put("launch_counter", Integer.toString(m58(sharedPreferences, "appsFlyerCount", false)));
            hashMap.put("gcd_conversion_data_timing", Long.toString(sharedPreferences.getLong("appsflyerGetConversionDataTiming", 0)));
            String string4 = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.CHANNEL);
            if (string4 == null) {
                string4 = m32(weakReference, "CHANNEL");
            }
            hashMap.put(AppsFlyerProperties.CHANNEL, string4);
            hashMap.put("originalAppsflyerId", string2 != null ? string2 : "");
            if (this.f42) {
                try {
                    n nVar = new n(null, isTrackingStopped());
                    nVar.f179 = hashMap;
                    if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
                        AFLogger.afDebugLog("Main thread detected. Running callStats task in a new thread.");
                        nVar.execute(ServerConfigHandler.getUrl("https://stats.%s/stats"));
                        return;
                    }
                    AFLogger.afDebugLog(new StringBuilder("Running callStats task (on current thread: ").append(Thread.currentThread().toString()).append(" )").toString());
                    nVar.onPreExecute();
                    nVar.onPostExecute(nVar.doInBackground(ServerConfigHandler.getUrl("https://stats.%s/stats")));
                } catch (Throwable th) {
                    AFLogger.afErrorLog("Could not send callStats request", th);
                }
            } else {
                AFLogger.afDebugLog("Stats call is disabled, ignore ...");
            }
        }
    }

    /* access modifiers changed from: package-private */
    /* renamed from: ॱ  reason: contains not printable characters */
    public final Map<String, Object> m79(Context context, String str, String str2, String str3, String str4, boolean z, SharedPreferences sharedPreferences, boolean z2, Intent intent) {
        String r2;
        Object obj;
        Map<String, Object> hashMap = new HashMap<>();
        l.m150(context, hashMap);
        long time = new Date().getTime();
        hashMap.put("af_timestamp", Long.toString(time));
        Object r22 = e.m112(context, time);
        if (r22 != null) {
            hashMap.put("cksm_v1", r22);
        }
        try {
            if (!isTrackingStopped()) {
                AFLogger.afInfoLog(new StringBuilder("******* sendTrackingWithEvent: ").append(z2 ? "Launch" : str2).toString());
            } else {
                AFLogger.afInfoLog("SDK tracking has been stopped");
            }
            m45(context, LOG_TAG, "EVENT_CREATED_WITH_NAME", z2 ? "Launch" : str2);
            CacheManager.getInstance().init(context);
            try {
                List asList = Arrays.asList(context.getPackageManager().getPackageInfo(context.getPackageName(), 4096).requestedPermissions);
                if (!asList.contains("android.permission.INTERNET")) {
                    AFLogger.afWarnLog("Permission android.permission.INTERNET is missing in the AndroidManifest.xml");
                    m45(context, null, "PERMISSION_INTERNET_MISSING", null);
                }
                if (!asList.contains("android.permission.ACCESS_NETWORK_STATE")) {
                    AFLogger.afWarnLog("Permission android.permission.ACCESS_NETWORK_STATE is missing in the AndroidManifest.xml");
                }
                if (!asList.contains("android.permission.ACCESS_WIFI_STATE")) {
                    AFLogger.afWarnLog("Permission android.permission.ACCESS_WIFI_STATE is missing in the AndroidManifest.xml");
                }
            } catch (Exception e2) {
                AFLogger.afErrorLog("Exception while validation permissions. ", e2);
            }
            if (z) {
                hashMap.put("af_events_api", "1");
            }
            hashMap.put("brand", Build.BRAND);
            hashMap.put(UtilityConfig.KEY_DEVICE_INFO, Build.DEVICE);
            hashMap.put("product", Build.PRODUCT);
            hashMap.put("sdk", Integer.toString(Build.VERSION.SDK_INT));
            hashMap.put("model", Build.MODEL);
            hashMap.put("deviceType", Build.TYPE);
            if (z2) {
                if (!context.getSharedPreferences("appsflyer-data", 0).contains("appsFlyerCount")) {
                    if (!AppsFlyerProperties.getInstance().isOtherSdkStringDisabled()) {
                        hashMap.put("af_sdks", new StringBuilder().append(this.f41.m186("com.tune.Tune") ? 1 : 0).append(this.f41.m186("com.adjust.sdk.Adjust") ? 1 : 0).append(this.f41.m186("com.kochava.android.tracker.Feature") ? 1 : 0).append(this.f41.m186("io.branch.referral.Branch") ? 1 : 0).append(this.f41.m186("com.apsalar.sdk.Apsalar") ? 1 : 0).append(this.f41.m186("com.localytics.android.Localytics") ? 1 : 0).append(this.f41.m186("com.tenjin.android.TenjinSDK") ? 1 : 0).append(this.f41.m186("place holder for TD") ? 1 : 0).append(this.f41.m186("it.partytrack.sdk.Track") ? 1 : 0).append(this.f41.m186("jp.appAdForce.android.LtvManager") ? 1 : 0).toString());
                        hashMap.put("batteryLevel", String.valueOf(m72(context)));
                    }
                    int i = 18;
                    if ("OPPO".equals(Build.BRAND)) {
                        i = 23;
                        AFLogger.afRDLog("OPPO device found");
                    }
                    if (Build.VERSION.SDK_INT >= i) {
                        AFLogger.afRDLog(new StringBuilder("OS SDK is=").append(Build.VERSION.SDK_INT).append("; use KeyStore").toString());
                        AFKeystoreWrapper aFKeystoreWrapper = new AFKeystoreWrapper(context);
                        if (!aFKeystoreWrapper.m14()) {
                            aFKeystoreWrapper.m16(t.m199(new WeakReference(context)));
                            AppsFlyerProperties.getInstance().set("KSAppsFlyerId", aFKeystoreWrapper.m18());
                            AppsFlyerProperties.getInstance().set("KSAppsFlyerRICounter", String.valueOf(aFKeystoreWrapper.m15()));
                        } else {
                            aFKeystoreWrapper.m17();
                            AppsFlyerProperties.getInstance().set("KSAppsFlyerId", aFKeystoreWrapper.m18());
                            AppsFlyerProperties.getInstance().set("KSAppsFlyerRICounter", String.valueOf(aFKeystoreWrapper.m15()));
                        }
                    } else {
                        AFLogger.afRDLog(new StringBuilder("OS SDK is=").append(Build.VERSION.SDK_INT).append("; no KeyStore usage").toString());
                    }
                }
                long j = context.getSharedPreferences("appsflyer-data", 0).getLong("AppsFlyerTimePassedSincePrevLaunch", 0);
                long currentTimeMillis = System.currentTimeMillis();
                m55(context, "AppsFlyerTimePassedSincePrevLaunch", currentTimeMillis);
                hashMap.put("timepassedsincelastlaunch", Long.toString(j > 0 ? (currentTimeMillis - j) / 1000 : -1));
                Object string = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.ONELINK_ID);
                if (string != null) {
                    hashMap.put("onelink_id", string);
                    hashMap.put("ol_ver", AppsFlyerProperties.getInstance().getString("onelinkVersion"));
                }
            } else {
                SharedPreferences sharedPreferences2 = context.getSharedPreferences("appsflyer-data", 0);
                SharedPreferences.Editor edit = sharedPreferences2.edit();
                try {
                    String string2 = sharedPreferences2.getString("prev_event_name", null);
                    if (string2 != null) {
                        JSONObject jSONObject = new JSONObject();
                        jSONObject.put("prev_event_timestamp", new StringBuilder().append(sharedPreferences2.getLong("prev_event_timestamp", -1)).toString());
                        jSONObject.put("prev_event_value", sharedPreferences2.getString("prev_event_value", null));
                        jSONObject.put("prev_event_name", string2);
                        hashMap.put("prev_event", jSONObject.toString());
                    }
                    edit.putString("prev_event_name", str2);
                    edit.putString("prev_event_value", str3);
                    edit.putLong("prev_event_timestamp", System.currentTimeMillis());
                    if (Build.VERSION.SDK_INT >= 9) {
                        edit.apply();
                    } else {
                        edit.commit();
                    }
                } catch (Exception e3) {
                    AFLogger.afErrorLog("Error while processing previous event.", e3);
                }
            }
            Object string3 = AppsFlyerProperties.getInstance().getString("KSAppsFlyerId");
            String string4 = AppsFlyerProperties.getInstance().getString("KSAppsFlyerRICounter");
            if (!(string3 == null || string4 == null || Integer.valueOf(string4).intValue() <= 0)) {
                hashMap.put("reinstallCounter", string4);
                hashMap.put("originalAppsflyerId", string3);
            }
            Object string5 = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.ADDITIONAL_CUSTOM_DATA);
            if (string5 != null) {
                hashMap.put("customData", string5);
            }
            try {
                context.getPackageManager().getInstallerPackageName(context.getPackageName());
                if ("com.android.vending" != 0) {
                    hashMap.put("installer_package", "com.android.vending");
                }
            } catch (Exception e4) {
                AFLogger.afErrorLog("Exception while getting the app's installer package. ", e4);
            }
            String string6 = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.EXTENSION);
            if (string6 != null && string6.length() > 0) {
                hashMap.put(AppsFlyerProperties.EXTENSION, string6);
            }
            WeakReference weakReference = new WeakReference(context);
            String string7 = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.CHANNEL);
            if (string7 == null) {
                string7 = m32(weakReference, "CHANNEL");
            }
            Object r3 = m31(context, string7);
            if (r3 != null) {
                hashMap.put(AppsFlyerProperties.CHANNEL, r3);
            }
            if ((r3 != null && !r3.equals(string7)) || (r3 == null && string7 != null)) {
                hashMap.put("af_latestchannel", string7);
            }
            SharedPreferences sharedPreferences3 = context.getSharedPreferences("appsflyer-data", 0);
            if (sharedPreferences3.contains("INSTALL_STORE")) {
                r2 = sharedPreferences3.getString("INSTALL_STORE", null);
            } else {
                r2 = !context.getSharedPreferences("appsflyer-data", 0).contains("appsFlyerCount") ? m32(new WeakReference(context), "AF_STORE") : null;
                m66(context, "INSTALL_STORE", r2);
            }
            if (r2 != null) {
                hashMap.put("af_installstore", r2.toLowerCase());
            }
            SharedPreferences sharedPreferences4 = context.getSharedPreferences("appsflyer-data", 0);
            String string8 = AppsFlyerProperties.getInstance().getString("preInstallName");
            if (string8 == null) {
                if (sharedPreferences4.contains("preInstallName")) {
                    string8 = sharedPreferences4.getString("preInstallName", null);
                } else {
                    if (!context.getSharedPreferences("appsflyer-data", 0).contains("appsFlyerCount")) {
                        File r23 = m25(m61(PRE_INSTALL_SYSTEM_RO_PROP));
                        if (r23 == null || !r23.exists()) {
                            r23 = m25(m50(AF_PRE_INSTALL_PATH, context.getPackageManager(), context.getPackageName()));
                        }
                        if (r23 == null || !r23.exists()) {
                            r23 = m25(PRE_INSTALL_SYSTEM_DEFAULT);
                        }
                        File r32 = r23 == null || !r23.exists() ? m25(PRE_INSTALL_SYSTEM_DEFAULT_ETC) : r23;
                        if ((r32 == null || !r32.exists()) || (string8 = m60(r32, context.getPackageName())) == null) {
                            string8 = null;
                        }
                        if (string8 == null) {
                            string8 = m32(new WeakReference(context), "AF_PRE_INSTALL_NAME");
                        }
                    }
                    if (string8 != null) {
                        m66(context, "preInstallName", string8);
                    }
                }
                if (string8 != null) {
                    AppsFlyerProperties.getInstance().set("preInstallName", string8);
                }
            }
            if (string8 != null) {
                hashMap.put("af_preinstall_name", string8.toLowerCase());
            }
            String r24 = m32(new WeakReference(context), "AF_STORE");
            if (r24 != null) {
                hashMap.put("af_currentstore", r24.toLowerCase());
            }
            if (str == null || str.length() < 0) {
                String string9 = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.AF_KEY);
                if (string9 == null || string9.length() < 0) {
                    AFLogger.afInfoLog("AppsFlyer dev key is missing!!! Please use  AppsFlyerLib.getInstance().setAppsFlyerKey(...) to set it. ");
                    m45(context, LOG_TAG, "DEV_KEY_MISSING", null);
                    AFLogger.afInfoLog("AppsFlyer will not track this event.");
                    return null;
                }
                hashMap.put("appsflyerKey", string9);
            } else {
                hashMap.put("appsflyerKey", str);
            }
            Object string10 = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.APP_USER_ID);
            if (string10 != null) {
                hashMap.put("appUserId", string10);
            }
            Object string11 = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.USER_EMAILS);
            if (string11 != null) {
                hashMap.put("user_emails", string11);
            } else {
                String string12 = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.USER_EMAIL);
                if (string12 != null) {
                    hashMap.put("sha1_el", q.m172(string12));
                }
            }
            if (str2 != null) {
                hashMap.put("eventName", str2);
                if (str3 != null) {
                    hashMap.put("eventValue", str3);
                }
            }
            if (AppsFlyerProperties.getInstance().getString("appid") != null) {
                hashMap.put("appid", AppsFlyerProperties.getInstance().getString("appid"));
            }
            String string13 = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.CURRENCY_CODE);
            if (string13 != null) {
                if (string13.length() != 3) {
                    AFLogger.afWarnLog(new StringBuilder("WARNING: currency code should be 3 characters!!! '").append(string13).append("' is not a legal value.").toString());
                }
                hashMap.put(FirebaseAnalytics.Param.CURRENCY, string13);
            }
            Object string14 = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.IS_UPDATE);
            if (string14 != null) {
                hashMap.put("isUpdate", string14);
            }
            hashMap.put("af_preinstalled", Boolean.toString(isPreInstalledApp(context)));
            if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.COLLECT_FACEBOOK_ATTR_ID, true)) {
                try {
                    context.getPackageManager().getApplicationInfo("com.facebook.katana", 0);
                    obj = getAttributionId(context.getContentResolver());
                } catch (PackageManager.NameNotFoundException e5) {
                    obj = null;
                    AFLogger.afWarnLog("Exception while collecting facebook's attribution ID. ");
                } catch (Throwable th) {
                    AFLogger.afErrorLog("Exception while collecting facebook's attribution ID. ", th);
                    obj = null;
                }
                if (obj != null) {
                    hashMap.put("fb", obj);
                }
            }
            if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.DEVICE_TRACKING_DISABLED, false)) {
                hashMap.put(AppsFlyerProperties.DEVICE_TRACKING_DISABLED, "true");
            } else {
                SharedPreferences sharedPreferences5 = context.getSharedPreferences("appsflyer-data", 0);
                boolean z3 = AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.COLLECT_IMEI, true);
                String string15 = sharedPreferences5.getString("imeiCached", null);
                String str5 = null;
                if (z3) {
                    if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.COLLECT_ANDROID_ID_OR_IMEI_FORCE_BY_USER, false) || !m38(context)) {
                        try {
                            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
                            String str6 = (String) telephonyManager.getClass().getMethod("getDeviceId", new Class[0]).invoke(telephonyManager, new Object[0]);
                            if (str6 != null) {
                                str5 = str6;
                            } else if (this.f36 != null) {
                                str5 = this.f36;
                            } else {
                                str5 = string15 != null ? string15 : null;
                            }
                        } catch (InvocationTargetException e6) {
                            AFLogger.afWarnLog("WARNING: READ_PHONE_STATE is missing.");
                        } catch (Exception e7) {
                            AFLogger.afErrorLog("WARNING: READ_PHONE_STATE is missing. ", e7);
                        }
                    } else if (this.f36 != null) {
                        str5 = this.f36;
                    }
                } else if (this.f36 != null) {
                    str5 = this.f36;
                }
                if (str5 != null) {
                    m66(context, "imeiCached", str5);
                    hashMap.put("imei", str5);
                } else {
                    AFLogger.afInfoLog("IMEI was not collected.");
                }
                boolean z4 = AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.COLLECT_ANDROID_ID, true);
                String string16 = sharedPreferences5.getString("androidIdCached", null);
                String str7 = null;
                if (z4) {
                    if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.COLLECT_ANDROID_ID_OR_IMEI_FORCE_BY_USER, false) || !m38(context)) {
                        try {
                            String string17 = Settings.Secure.getString(context.getContentResolver(), "android_id");
                            if (string17 != null) {
                                str7 = string17;
                            } else if (this.f43 != null) {
                                str7 = this.f43;
                            } else {
                                if (string16 == null) {
                                    string16 = null;
                                }
                                str7 = string16;
                            }
                        } catch (Exception e8) {
                            AFLogger.afErrorLog(e8.getMessage(), e8);
                        }
                    } else if (this.f43 != null) {
                        str7 = this.f43;
                    }
                } else if (this.f43 != null) {
                    str7 = this.f43;
                }
                if (str7 != null) {
                    m66(context, "androidIdCached", str7);
                    hashMap.put("android_id", str7);
                } else {
                    AFLogger.afInfoLog("Android ID was not collected.");
                }
            }
            try {
                Object r25 = t.m199(new WeakReference(context));
                if (r25 != null) {
                    hashMap.put("uid", r25);
                }
            } catch (Exception e9) {
                AFLogger.afErrorLog(new StringBuilder("ERROR: could not get uid ").append(e9.getMessage()).toString(), e9);
            }
            try {
                hashMap.put("lang", Locale.getDefault().getDisplayLanguage());
            } catch (Exception e10) {
                AFLogger.afErrorLog("Exception while collecting display language name. ", e10);
            }
            try {
                hashMap.put("lang_code", Locale.getDefault().getLanguage());
            } catch (Exception e11) {
                AFLogger.afErrorLog("Exception while collecting display language code. ", e11);
            }
            try {
                hashMap.put("country", Locale.getDefault().getCountry());
            } catch (Exception e12) {
                AFLogger.afErrorLog("Exception while collecting country name. ", e12);
            }
            hashMap.put("platformextension", this.f41.m185());
            m29(context, hashMap);
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd_HHmmssZ", Locale.US);
            if (Build.VERSION.SDK_INT >= 9) {
                try {
                    long j2 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).firstInstallTime;
                    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
                    hashMap.put("installDate", simpleDateFormat.format(new Date(j2)));
                } catch (Exception e13) {
                    AFLogger.afErrorLog("Exception while collecting install date. ", e13);
                }
            }
            try {
                PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
                if (packageInfo.versionCode > sharedPreferences.getInt("versionCode", 0)) {
                    m65(context, "appsflyerConversionDataRequestRetries", 0);
                    m65(context, "versionCode", packageInfo.versionCode);
                }
                hashMap.put("app_version_code", Integer.toString(packageInfo.versionCode));
                hashMap.put("app_version_name", packageInfo.versionName);
                if (Build.VERSION.SDK_INT >= 9) {
                    long j3 = packageInfo.firstInstallTime;
                    long j4 = packageInfo.lastUpdateTime;
                    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
                    hashMap.put("date1", simpleDateFormat.format(new Date(j3)));
                    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
                    hashMap.put("date2", simpleDateFormat.format(new Date(j4)));
                    String string18 = context.getSharedPreferences("appsflyer-data", 0).getString("appsFlyerFirstInstall", null);
                    if (string18 == null) {
                        if (!context.getSharedPreferences("appsflyer-data", 0).contains("appsFlyerCount")) {
                            AFLogger.afDebugLog("AppsFlyer: first launch detected");
                            string18 = simpleDateFormat.format(new Date());
                        } else {
                            string18 = "";
                        }
                        m66(context, "appsFlyerFirstInstall", string18);
                    }
                    AFLogger.afInfoLog("AppsFlyer: first launch date: ".concat(String.valueOf(string18)));
                    hashMap.put("firstLaunchDate", string18);
                }
            } catch (Throwable th2) {
                AFLogger.afErrorLog("Exception while collecting app version data ", th2);
            }
            if (str4.length() > 0) {
                hashMap.put("referrer", str4);
            }
            Object string19 = sharedPreferences.getString("extraReferrers", null);
            if (string19 != null) {
                hashMap.put("extraReferrers", string19);
            }
            String string20 = AppsFlyerProperties.getInstance().getString("afUninstallToken");
            if (string20 != null) {
                hashMap.put("af_gcm_token", a.m101(string20).m105());
            }
            this.f40 = x.m223(context);
            AFLogger.afDebugLog(new StringBuilder("didConfigureTokenRefreshService=").append(this.f40).toString());
            if (!this.f40) {
                hashMap.put("tokenRefreshConfigured", Boolean.FALSE);
            }
            if (z2) {
                if (this.f32 != null) {
                    JSONObject jSONObject2 = new JSONObject(this.f32);
                    jSONObject2.put("isPush", "true");
                    hashMap.put("af_deeplink", jSONObject2.toString());
                }
                this.f32 = null;
            }
            if (z2) {
                Uri uri = null;
                if (intent != null && "android.intent.action.VIEW".equals(intent.getAction())) {
                    uri = intent.getData();
                }
                if (uri != null) {
                    m67(context, hashMap, uri);
                } else if (this.f27 != null) {
                    m67(context, hashMap, this.f27);
                }
            }
            if (this.f31) {
                hashMap.put("testAppMode_retargeting", "true");
                String jSONObject3 = new JSONObject(hashMap).toString();
                Intent intent2 = new Intent("com.appsflyer.testIntgrationBroadcast");
                intent2.putExtra(SpeechConstant.PARAMS, jSONObject3);
                context.sendBroadcast(intent2);
                AFLogger.afInfoLog("Sent retargeting params to test app");
            }
            String referrer = AppsFlyerProperties.getInstance().getReferrer(context);
            if (System.currentTimeMillis() - this.f37 <= 30000 && referrer != null && referrer.contains("AppsFlyer_Test")) {
                hashMap.put("testAppMode", "true");
                String jSONObject4 = new JSONObject(hashMap).toString();
                Intent intent3 = new Intent("com.appsflyer.testIntgrationBroadcast");
                intent3.putExtra(SpeechConstant.PARAMS, jSONObject4);
                context.sendBroadcast(intent3);
                AFLogger.afInfoLog("Sent params to test app");
                AFLogger.afInfoLog("Test mode ended!");
                this.f37 = 0;
            }
            if (AppsFlyerProperties.getInstance().getString(ServerParameters.ADVERTISING_ID_PARAM) == null) {
                l.m150(context, hashMap);
                if (AppsFlyerProperties.getInstance().getString(ServerParameters.ADVERTISING_ID_PARAM) != null) {
                    hashMap.put("GAID_retry", "true");
                } else {
                    hashMap.put("GAID_retry", HttpState.PREEMPTIVE_DEFAULT);
                }
            }
            k r26 = l.m149(context.getContentResolver());
            if (r26 != null) {
                hashMap.put("amazon_aid", r26.m147());
                hashMap.put("amazon_aid_limit", String.valueOf(r26.m148()));
            }
            String referrer2 = AppsFlyerProperties.getInstance().getReferrer(context);
            if (referrer2 != null && referrer2.length() > 0 && hashMap.get("referrer") == null) {
                hashMap.put("referrer", referrer2);
            }
            boolean equals = "true".equals(sharedPreferences.getString("sentSuccessfully", ""));
            hashMap.put("registeredUninstall", Boolean.valueOf(sharedPreferences.getBoolean("sentRegisterRequestToAF", false)));
            int r4 = m58(sharedPreferences, "appsFlyerCount", z2);
            hashMap.put("counter", Integer.toString(r4));
            hashMap.put("iaecounter", Integer.toString(m58(sharedPreferences, "appsFlyerInAppEventCount", str2 != null)));
            if (z2 && r4 == 1) {
                AppsFlyerProperties.getInstance().setFirstLaunchCalled();
                if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.AF_WAITFOR_CUSTOMERID, false)) {
                    hashMap.put("wait_cid", Boolean.toString(true));
                }
            }
            hashMap.put("isFirstCall", Boolean.toString(!equals));
            HashMap hashMap2 = new HashMap();
            hashMap2.put("cpu_abi", m61("ro.product.cpu.abi"));
            hashMap2.put("cpu_abi2", m61("ro.product.cpu.abi2"));
            hashMap2.put("arch", m61("os.arch"));
            hashMap2.put("build_display_id", m61("ro.build.display.id"));
            if (z2) {
                if (this.f35) {
                    i iVar = i.e.f155;
                    Location r33 = i.m140(context);
                    HashMap hashMap3 = new HashMap(3);
                    if (r33 != null) {
                        hashMap3.put("lat", String.valueOf(r33.getLatitude()));
                        hashMap3.put("lon", String.valueOf(r33.getLongitude()));
                        hashMap3.put("ts", String.valueOf(r33.getTime()));
                    }
                    if (!hashMap3.isEmpty()) {
                        hashMap2.put("loc", hashMap3);
                    }
                }
                d.c r34 = d.C0083d.f111.m108(context);
                hashMap2.put("btl", Float.toString(r34.m110()));
                if (r34.m109() != null) {
                    hashMap2.put("btch", r34.m109());
                }
                if (2 >= r4) {
                    List<Map<String, Object>> r35 = f.m119(context).m123();
                    if (!r35.isEmpty()) {
                        hashMap2.put("sensors", r35);
                    }
                }
            }
            hashMap2.put(AFScreenManager.SCREEN_KEY, AFScreenManager.getScreenMetrics(context));
            hashMap.put("deviceData", hashMap2);
            new q();
            String str8 = (String) hashMap.get("af_timestamp");
            hashMap.put("af_v", q.m172(new StringBuilder().append(((String) hashMap.get("appsflyerKey")).substring(0, 7)).append(((String) hashMap.get("uid")).substring(0, 7)).append(str8.substring(str8.length() - 7)).toString()));
            new q();
            hashMap.put("af_v2", q.m172(q.m170(new StringBuilder().append(new StringBuilder().append(new StringBuilder().append(new StringBuilder().append(new StringBuilder().append((String) hashMap.get("appsflyerKey")).append(hashMap.get("af_timestamp")).toString()).append(hashMap.get("uid")).toString()).append(hashMap.get("installDate")).toString()).append(hashMap.get("counter")).toString()).append(hashMap.get("iaecounter")).toString())));
            if (sharedPreferences.contains(IS_STOP_TRACKING_USED)) {
                hashMap.put("istu", String.valueOf(sharedPreferences.getBoolean(IS_STOP_TRACKING_USED, false)));
            }
        } catch (Throwable th3) {
            AFLogger.afErrorLog(th3.getLocalizedMessage(), th3);
        }
        return hashMap;
    }
}